Skip to content
Classcorev0.10.0

Bus

Registers and dispatches subscribers. Subscribers run on a programmatic or framework publish. Accessed via core.bus. Do not construct it directly.

Member visibility

Filter class members by access level.

constructor

Constructs a new instance of the Bus class

Bus(core: CoreBase)

Always throws. Call publish to reach subscribers and listeners together.

emit()

public override emit<KeyOfSubscribers>(
    event: KeyOfSubscribers,
    _args: SubscriptionTuples[KeyOfSubscribers]
): never

Throws:

A SeedcordTypeError with CoreBusEmitUnavailable. emit reaches only the on() listeners.

Deprecated

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): number

Inherited from:TypedEventEmitter

off()

Removes a previously registered listener.

off<TEventKey>(
    event: TEventKey,
    listener: (...args: TEvents[TEventKey]) => void
): this

Inherited from:TypedEventEmitter

on()

Registers a persistent listener for an event.

on<TEventKey>(
    event: TEventKey,
    listener: (...args: TEvents[TEventKey]) => void
): this

Inherited from:TypedEventEmitter

once()

Registers a listener removed after its first invocation.

once<TEventKey>(
    event: TEventKey,
    listener: (...args: TEvents[TEventKey]) => void
): this

Inherited from:TypedEventEmitter

publish()

Publishes 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]
): boolean
Parameter: event

The subscription key to publish

Parameter: data

Payload passed to each subscriber

removeAllListeners()

Removes every listener for an event, or for all events when no event is given.

removeAllListeners(
    event?: EventKey<TEvents>
): this

Inherited from:TypedEventEmitter

removeListener()

Alias of off.

removeListener<TEventKey>(
    event: TEventKey,
    listener: (...args: TEvents[TEventKey]) => void
): this

Inherited 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]>
Parameter: event

The event to wait for.

Parameter: options

An optional filter, abort signal, and timeout.

Inherited from:TypedEventEmitter