Skip to main content

The event system allows you to emit events to the backend and listen to events from it.

Table of contents#

Interfaces#

Type aliases#

EventCallback#

Ƭ EventCallback<T>: (event: Event<T>) => void

Type parameters:#

Name
T

Type declaration:#

▸ (event: Event<T>): void

Parameters:#

NameType
eventEvent<T>

Returns: void

Defined in: event.ts:23


UnlistenFn#

Ƭ UnlistenFn: () => void

Type declaration:#

▸ (): void

Returns: void

Defined in: event.ts:25

Functions#

emit#

emit(event: string, payload?: string): Promise<void>

Emits an event to the backend.

Parameters:#

NameTypeDescription
eventstringEvent name
payload?string-

Returns: Promise<void>

Defined in: event.ts:91


listen#

listen<T>(event: string, handler: EventCallback<T>): Promise<UnlistenFn>

Listen to an event from the backend.

Type parameters:#

Name
T

Parameters:#

NameTypeDescription
eventstringEvent name
handlerEventCallback<T>Event handler callback

Returns: Promise<UnlistenFn>

A promise resolving to a function to unlisten to the event.

Defined in: event.ts:51


once#

once<T>(event: string, handler: EventCallback<T>): Promise<UnlistenFn>

Listen to an one-off event from the backend.

Type parameters:#

Name
T

Parameters:#

NameTypeDescription
eventstringEvent name
handlerEventCallback<T>Event handler callback

Returns: Promise<UnlistenFn>

A promise resolving to a function to unlisten to the event.

Defined in: event.ts:74