Skip to content

Event<T>

Allows attaching handlers and broadcasting events.

Type Parameters

T extends unknown[]

Implements

Constructors

new Event()

ts
new Event<T>(options?): Event<T>

Creates new event instance.

Parameters

options?: EventOptions

Returns

Event<T>

Defined in

event.ts:33 ↗

Accessors

last

ts
get last(): undefined | [...T[]]

In case event was broadcast at least once, returns last payload; undefined otherwise.

Returns

undefined | [...T[]]

In case event was broadcast at least once, returns last payload; undefined otherwise.

Implementation of

EventSubscriber.last

Defined in

event.ts:79 ↗

Methods

broadcast()

ts
broadcast(...args): void

Notifies attached handlers with specified payload.

Parameters

• ...args: [...T[]]

The payload of the notification.

Returns

void

Implementation of

EventBroadcaster.broadcast

Defined in

event.ts:39 ↗


subscribe()

ts
subscribe(handler): string

Attaches specified handler for events emitted by this event instance.

Parameters

handler

The handler to attach.

Returns

string

Implementation of

EventSubscriber.subscribe

Defined in

event.ts:47 ↗


subscribeById()

ts
subscribeById(id, handler): void

Attaches handler with specified identifier for events emitted by this event instance.

Parameters

id: string

Identifier of the handler.

handler

The handler to attach.

Returns

void

Defined in

event.ts:64 ↗


unsubscribe()

ts
unsubscribe(handler): void

Detaches specified handler from events emitted by this event instance.

Parameters

handler

The handler to detach.

Returns

void

Implementation of

EventSubscriber.unsubscribe

Defined in

event.ts:55 ↗


unsubscribeById()

ts
unsubscribeById(id): void

Detaches handler with specified identifier from events emitted by this event instance.

Parameters

id: string

Identifier of the handler.

Returns

void

Defined in

event.ts:72 ↗