EventDispatcherBase
Defined in: packages/async/src/events/event-dispatcher-base.ts:44
Interface representing an object that allows listeners to register for event dispatching.
Extended by
Section titled “Extended by”Type Parameters
Section titled “Type Parameters”T extends unknown[] = never[]
Tuple type representing the arguments that will be passed to listener functions.
Implements
Section titled “Implements”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new EventDispatcherBase<
T>():EventDispatcherBase<T>
Returns
Section titled “Returns”EventDispatcherBase<T>
Methods
Section titled “Methods”isSubscribed()
Section titled “isSubscribed()”isSubscribed(
subscriber):boolean
Defined in: packages/async/src/events/event-dispatcher-base.ts:99
Tests whether a listener is registered.
Parameters
Section titled “Parameters”subscriber
Section titled “subscriber”Callable<T>
Returns
Section titled “Returns”boolean
True if the listener is registered, false otherwise.
Implementation of
Section titled “Implementation of”subscribe()
Section titled “subscribe()”subscribe(
subscriber,options?):Callable|null
Defined in: packages/async/src/events/event-dispatcher-base.ts:54
Registers a listener function to be called when the event is dispatched.
If the listener is already registered, this method has no effect.
Parameters
Section titled “Parameters”subscriber
Section titled “subscriber”Callable<T>
options?
Section titled “options?”EventDispatcherSubscribeOptions
Optional settings for the subscription.
Returns
Section titled “Returns”Callable | null
A function that can be called to unsubscribe the listener, or null if the listener was already registered.
Implementation of
Section titled “Implementation of”unsubscribe()
Section titled “unsubscribe()”unsubscribe(
subscriber):void
Defined in: packages/async/src/events/event-dispatcher-base.ts:88
Unregisters a previously registered listener function.
If the listener is not registered, this method has no effect.
Parameters
Section titled “Parameters”subscriber
Section titled “subscriber”Callable<T>
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”wait()
Section titled “wait()”wait(
options?):Promise<T>
Defined in: packages/async/src/events/event-dispatcher-base.ts:103
Waits for the next occurrence of the event, optionally matching a predicate.
This is a convenience method that subscribes to the dispatcher, waits for the next event that matches the predicate (if provided), and then unsubscribes automatically.
Parameters
Section titled “Parameters”options?
Section titled “options?”Optional settings including predicate and abort signal.
Returns
Section titled “Returns”Promise<T>
A promise that resolves with the next event arguments as an array.