@serenity-is/sleekgrid / EventEmitter

Class: EventEmitter<TArgs, TEventData>

A simple publisher-subscriber implementation.

Type Parameters

TArgs = any

TEventData extends IEventData = IEventData

Constructors

new EventEmitter()

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

Returns

EventEmitter<TArgs, TEventData>

Methods

clear()

clear(): void

Returns

void

Defined in

core/event.ts:105


notify()

notify(args?, e?, scope?): any

Fires an event notifying all subscribers.

Parameters

args?

any

Additional data object to be passed to all handlers.

e?

TEventData

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

any

Defined in

core/event.ts:93


subscribe()

subscribe(fn): void

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

(e, args) => void

Event handler.

Returns

void

Defined in

core/event.ts:65


unsubscribe()

unsubscribe(fn): void

Removes an event handler added with subscribe(fn).

Parameters

fn

(e, args) => void

Event handler to be removed.

Returns

void

Defined in

core/event.ts:73