Record mapping each event name to the tuple of arguments passed to its listeners.
Record mapping each event name to the tuple of arguments passed to its listeners.
Synchronously invokes every listener registered for event, in registration order.
true if at least one listener was invoked, false if there were none.
The listener list is snapshotted before dispatch, so mutations made by handlers take effect only on subsequent emissions. Listeners are isolated: if one throws, the remaining listeners still run and the error is surfaced via console.error rather than swallowed silently (consistent with LocalMessageBus).
Returns the number of listeners currently registered for event.
The event name to count listeners for.
The count of registered listeners (0 if none).
Registers a listener that is invoked at most once: it is removed automatically before
being called the first time event is emitted.
This emitter, for chaining.
Remove a pending one-time listener by passing the same function reference to off.
Removes listeners for a single event, or for all events.
Optionalevent: keyof EventsThe event name to clear; if omitted, listeners for every event are removed.
This emitter, for chaining.
A lightweight, type-safe event emitter.
The
Eventstype parameter maps each event name to the tuple of argument types its listeners receive, so on, once, off, and emit are all checked against that map at compile time.Remarks
Listeners registered for the same event fire in registration order. During
emitthe listener list is snapshotted, so adding or removing listeners inside a handler does not affect the current dispatch. All mutating methods returnthisfor chaining.Example