IEventDispatcher
Defined in: packages/async/src/events/ievent-dispatcher.ts:38
Interface representing an object that allows listeners to register for event dispatching.
Type Parameters
Section titled “Type Parameters”T extends unknown[] = never[]
Tuple type representing the arguments that will be passed to listener functions.
Methods
Section titled “Methods”isSubscribed()
Section titled “isSubscribed()”isSubscribed(
listener):boolean
Defined in: packages/async/src/events/ievent-dispatcher.ts:69
Tests whether a listener is registered.
Parameters
Section titled “Parameters”listener
Section titled “listener”Callable<T>
The listener function to check.
Returns
Section titled “Returns”boolean
True if the listener is registered, false otherwise.
subscribe()
Section titled “subscribe()”subscribe(
listener,options?):Callable|null
Defined in: packages/async/src/events/ievent-dispatcher.ts:49
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”listener
Section titled “listener”Callable<T>
The listener function to call when the event is dispatched.
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.
unsubscribe()
Section titled “unsubscribe()”unsubscribe(
listener):void
Defined in: packages/async/src/events/ievent-dispatcher.ts:61
Unregisters a previously registered listener function.
If the listener is not registered, this method has no effect.
Parameters
Section titled “Parameters”listener
Section titled “listener”Callable<T>
The listener function to remove.
Returns
Section titled “Returns”void
wait()
Section titled “wait()”wait(
options?):Promise<T>
Defined in: packages/async/src/events/ievent-dispatcher.ts:82
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.