@serenity-is/sleekgrid / EventEmitter

Class: EventEmitter<TArgs, TEvent>

Defined in: src/core/event.ts:173

A simple publisher-subscriber implementation.

Type Parameters

TArgs

TArgs = any

TEvent

TEvent = { }

Constructors

Constructor

new EventEmitter<TArgs, TEvent>(): EventEmitter<TArgs, TEvent>

Returns

EventEmitter<TArgs, TEvent>

Methods

clear()

clear(): void

Defined in: src/core/event.ts:221

Returns

void


notify()

notify(args?, e?, scope?): EventData<TArgs, TEvent>

Defined in: src/core/event.ts:211

Fires an event notifying all subscribers.

Parameters

args?

TArgs

Additional data object to be passed to all handlers.

e?

TEvent

Optional. An EventData object to be passed to all handlers. For DOM events, an existing W3C/jQuery event object can be passed in.

scope?

object

Optional. The scope ("this") within which the handler will be executed. If not specified, the scope will be set to the Event instance.

Returns

EventData<TArgs, TEvent>


subscribe()

subscribe(fn): void

Defined in: src/core/event.ts:183

Adds an event handler to be called when the event is fired.

Event handler will receive two arguments - an EventData and the data object the event was fired with.

Parameters

fn

EventCallback<TArgs, TEvent>

Event handler.

Returns

void


unsubscribe()

unsubscribe(fn): void

Defined in: src/core/event.ts:191

Removes an event handler added with subscribe(fn).

Parameters

fn

EventCallback<TArgs, TEvent>

Event handler to be removed.

Returns

void