Skip to content

@serenity-is/sleekgrid / EventEmitter

Class: EventEmitter<TArgs, TEventData>

A simple publisher-subscriber implementation.

Type parameters

Name Type
TArgs any
TEventData extends IEventData = IEventData

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new EventEmitter<TArgs, TEventData>()

Type parameters

Name Type
TArgs any
TEventData extends IEventData = IEventData

Properties

_handlers

Private _handlers: EventListener<TArgs, TEventData>[] = []

Defined in

core/event.ts:60

Methods

clear

clear(): void

Returns

void

Defined in

core/event.ts:110


notify

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

Fires an event notifying all subscribers.

Parameters

Name Type Description
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:98


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.

Method

subscribe

Parameters

Name Type Description
fn EventListener<TArgs, TEventData> Event handler.

Returns

void

Defined in

core/event.ts:69


unsubscribe

unsubscribe(fn): void

Removes an event handler added with subscribe(fn).

Method

unsubscribe

Parameters

Name Type Description
fn EventListener<TArgs, TEventData> Event handler to be removed.

Returns

void

Defined in

core/event.ts:78