Skip to content

EventBus

Defined in: EventBus.ts:48

Typed publish/subscribe event bus.

E = EventMap

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

EventBus<E>

_setErrorBoundary(boundary): void

Defined in: EventBus.ts:60

Internal

Wire the error boundary so a throwing handler or tap observer is reported instead of stopping every other listener. EventBus has no EngineContext of its own (a no-arg constructor, usable standalone), so Engine calls this once after both are constructed.

ErrorBoundary

void


clear(event?): void

Defined in: EventBus.ts:139

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:95

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:65

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:82

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:131

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

(event, data) => void

() => void