class Bus extends TypedEventEmitter<SubscriptionTuples>Member visibility
Filter class members by access level.
Bus(core: CoreBase)Showing members with Protected visibility and higher.
protected core: CoreBaseemit()
Emits an event, invoking each listener with the payload tuple. Returns true when the event had listeners.
emit<TEventKey>(
event: TEventKey,
args: TEvents[TEventKey]
): booleanInherited from:TypedEventEmitter
eventNames()
Returns the event names with at least one listener.
eventNames(): EventKey<TEvents>[]Inherited from:TypedEventEmitter
listenerCount()
Counts the listeners registered for an event.
listenerCount<TEventKey>(event: TEventKey): numberInherited from:TypedEventEmitter
off()
Removes a previously registered listener.
off<TEventKey>(
event: TEventKey,
listener: (...args: TEvents[TEventKey]) => void
): thisInherited from:TypedEventEmitter
on()
Registers a persistent listener for an event.
on<TEventKey>(
event: TEventKey,
listener: (...args: TEvents[TEventKey]) => void
): thisInherited from:TypedEventEmitter
once()
Registers a listener removed after its first invocation.
once<TEventKey>(
event: TEventKey,
listener: (...args: TEvents[TEventKey]) => void
): thisInherited from:TypedEventEmitter
Publishes an event to its subscribers and native listeners.
Fire-and-forget. Subscriber handlers run asynchronously and this returns before they finish. A caller cannot assume a side effect has completed. Errors thrown by a subscriber or by an on() listener are caught and logged, never surfaced here. One throwing listener does not stop the others. Subscribers on one key run concurrently and carry no ordering guarantee. A 'once' subscriber is marked as executed when it starts, even if it throws. It never runs twice.
The framework's own keys are excluded. Subscribe to those and listen with on. The framework is their only publisher.
public publish<KeyOfSubscribers>(
event: KeyOfSubscribers,
data: AllSubscriptions[KeyOfSubscribers]
): booleaneventThe subscription key to publish
dataPayload passed to each subscriber
removeAllListeners()
Removes every listener for an event, or for all events when no event is given.
removeAllListeners(
event?: EventKey<TEvents>
): thisInherited from:TypedEventEmitter
removeListener()
Alias of off.
removeListener<TEventKey>(
event: TEventKey,
listener: (...args: TEvents[TEventKey]) => void
): thisInherited from:TypedEventEmitter
waitFor()
Waits for the next emission of an event, resolving with its payload tuple. With a filter, resolves on the first payload the filter accepts.
async waitFor<TEventKey>(
event: TEventKey,
options?: WaitForOptions<TEvents[TEventKey]>
): Promise<TEvents[TEventKey]>eventThe event to wait for.
optionsAn optional filter, abort signal, and timeout.
Inherited from:TypedEventEmitter