EventBus
Defined in: EventBus.ts:48
Typed publish/subscribe event bus.
Type Parameters
Section titled “Type Parameters”E = EventMap
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new EventBus<
E>():EventBus<E>
Returns
Section titled “Returns”EventBus<E>
Methods
Section titled “Methods”_setErrorBoundary()
Section titled “_setErrorBoundary()”_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.
Parameters
Section titled “Parameters”boundary
Section titled “boundary”Returns
Section titled “Returns”void
clear()
Section titled “clear()”clear(
event?):void
Defined in: EventBus.ts:155
Remove all handlers for an event, or all handlers if no event specified.
Parameters
Section titled “Parameters”event?
Section titled “event?”keyof E
Returns
Section titled “Returns”void
emit()
Section titled “emit()”emit<
K>(event,data):void
Defined in: EventBus.ts:109
Emit an event. Handlers are called synchronously in registration order.
Type Parameters
Section titled “Type Parameters”K extends string | number | symbol
Parameters
Section titled “Parameters”K
E[K]
Returns
Section titled “Returns”void
on<
K>(event,handler): () =>void
Defined in: EventBus.ts:69
Subscribe to an event. Returns an unsubscribe function bound to this registration: the same function registered twice fires twice, and each unsubscribe removes only its own entry, once.
Type Parameters
Section titled “Type Parameters”K extends string | number | symbol
Parameters
Section titled “Parameters”K
handler
Section titled “handler”(data) => void
Returns
Section titled “Returns”() => void
once()
Section titled “once()”once<
K>(event,handler): () =>void
Defined in: EventBus.ts:91
Subscribe to an event, auto-unsubscribe after first emission.
Type Parameters
Section titled “Type Parameters”K extends string | number | symbol
Parameters
Section titled “Parameters”K
handler
Section titled “handler”(data) => void
Returns
Section titled “Returns”() => void
tap(
observer): () =>void
Defined in: EventBus.ts:147
Observe every emitted event. Observers run before the handlers of each emit, inside the same error boundary as a handler: a throwing observer is recorded, rethrown, and stops that emit’s handlers. Used by tooling such as the Inspector event log.
Parameters
Section titled “Parameters”observer
Section titled “observer”(event, data) => void
Returns
Section titled “Returns”() => void
Coding agents: fetch https://yage.dev/llms.txt first and prefer the Markdown references it links over these HTML pages. This page's Markdown counterpart is /llms/packages/core.md.