BeAsyncEvent<T extends AsyncListener> Class @beta
Manages a set of listeners for a particular event and notifies them when the event is raised.
Each listener is async (return a Promise
Like BeUnorderedEvent, this class uses a Set internally to support more performant removal
of old listeners. When a listener is removed during emit, it is marked for deferred removal instead
of mutating the set immediately. Despite the "unordered" implication, items in a Set are enumerated
in insertion order, which means that this class invokes the listeners in insertion order.
Listeners are managed exclusively through the disposal closure returned by addListener and
addOnce. There is no removeListener or has method — callers must capture the returned
closure to unsubscribe.
Methods
| Name | Description | |
|---|---|---|
| constructor<T extends AsyncListener>(options?: BeAsyncEventOptions): BeAsyncEvent<T> | ||
| addListener(listener: T, scope?: any): () => void | Registers a Listener to be executed whenever this event is raised. | |
| addOnce(listener: T, scope?: any): () => void | Registers a callback function to be executed only once when the event is raised. | |
| clear(): void | Clear all listeners from this BeAsyncEvent. | |
| raiseEvent(...args: Parameters<T>): Promise<void> | Raises the event by calling each registered listener with the supplied arguments. |
Properties
| Name | Type | Description | |
|---|---|---|---|
| numberOfListeners Accessor ReadOnly | number | The number of listeners currently subscribed to the event. |
Defined in
- core/bentley/src/BeEvent.ts Line 305
Last Updated: 05 November, 2026