Skip to content

EventBus

Defined in: EventBus.ts:47

Typed publish/subscribe event bus.

E = EventMap

new EventBus<E>(): EventBus<E>

EventBus<E>

clear(event?): void

Defined in: EventBus.ts:107

Remove all handlers for an event, or all handlers if no event specified.

keyof E

void


emit<K>(event, data): void

Defined in: EventBus.ts:78

Emit an event. Handlers are called synchronously in registration order.

K extends string | number | symbol

K

E[K]

void


on<K>(event, handler): () => void

Defined in: EventBus.ts:52

Subscribe to an event. Returns an unsubscribe function.

K extends string | number | symbol

K

(data) => void

() => void


once<K>(event, handler): () => void

Defined in: EventBus.ts:69

Subscribe to an event, auto-unsubscribe after first emission.

K extends string | number | symbol

K

(data) => void

() => void


tap(observer): () => void

Defined in: EventBus.ts:99

Observe every emitted event without affecting handler order or control flow. Used by tooling such as the Inspector event log.

(event, data) => void

() => void