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: CoreBaseCall publish to reach subscribers and listeners together.
public override emit<KeyOfSubscribers>(
event: KeyOfSubscribers,
_args: SubscriptionTuples[KeyOfSubscribers]
): neverThrows:
A SeedcordTypeError every time, with CoreBusEmitUnavailable. emit reaches only the on() listeners.
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
public override off<KeyOfSubscribers>(
event: KeyOfSubscribers,
listener: BusListener<KeyOfSubscribers>
): thispublic override on<KeyOfSubscribers>(
event: KeyOfSubscribers,
listener: BusListener<KeyOfSubscribers>
): thisRegisters a listener that runs on the next publish of the key only. It can be async, like on.
public override once<KeyOfSubscribers>(
event: KeyOfSubscribers,
listener: BusListener<KeyOfSubscribers>
): thisPublishes an event to its subscribers and native listeners.
Fire-and-forget. Subscriber handlers run asynchronously and this returns before they finish.
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
Alias of off.
public override removeListener<KeyOfSubscribers>(
event: KeyOfSubscribers,
listener: BusListener<KeyOfSubscribers>
): thiswaitFor()
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