Skip to content

EventDispatcherBase

Defined in: packages/async/src/events/event-dispatcher-base.ts:44

Interface representing an object that allows listeners to register for event dispatching.

T extends unknown[] = never[]

Tuple type representing the arguments that will be passed to listener functions.

new EventDispatcherBase<T>(): EventDispatcherBase<T>

EventDispatcherBase<T>

isSubscribed(subscriber): boolean

Defined in: packages/async/src/events/event-dispatcher-base.ts:99

Tests whether a listener is registered.

Callable<T>

boolean

True if the listener is registered, false otherwise.

IEventDispatcher.isSubscribed


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.

Callable<T>

EventDispatcherSubscribeOptions

Optional settings for the subscription.

Callable | null

A function that can be called to unsubscribe the listener, or null if the listener was already registered.

IEventDispatcher.subscribe


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.

Callable<T>

void

IEventDispatcher.unsubscribe


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.

EventDispatcherWaitOptions<T>

Optional settings including predicate and abort signal.

Promise<T>

A promise that resolves with the next event arguments as an array.

IEventDispatcher.wait