async-events
Async event emitter.
Classes
Section titled “Classes”| Class | Description |
|---|---|
| AsyncEventRefDisposable | An AsyncDisposableEx that unregisters an AsyncEventRef on dispose, via the event source stored on the ref itself. Async counterpart of the native EventRefDisposable. |
| AsyncEvents | A class that extends AsyncEventsBase and provides public methods for triggering events. This class exists as parity with Obsidian’s Events. But exposing publicly trigger() methods violates encapsulation. Avoid using it in favor of AsyncEventsBase. |
| AsyncEventsBase | Async event source implementation. |
Interfaces
Section titled “Interfaces”| Interface | Description |
|---|---|
| AsyncEventRef | Async event reference. |
| AsyncEventSource | Async event emitter implementation. |
| AsyncEventTrigger | Interface exposing event-triggering methods for subclasses of mixin-created classes. These methods are protected at runtime but surfaced in the declaration type because TypeScript cannot represent protected in anonymous-class return types. |
| GenericAsyncEventSource | Interface for event source, used by AsyncEventRef so that refs can be stored regardless of the emitter’s EventMap. |
| SubscribeAsyncDisposableEventParams | Parameters for subscribeAsyncDisposableEvent. |
Functions
Section titled “Functions”| Function | Description |
|---|---|
| mixinAsyncEvents | Mixin that adds AsyncEventSource delegation to a base class. All event methods delegate to a private AsyncEventsBase instance. The EventMap generic is fixed at mixin-application time — if you need a class that is itself generic over its event map, use composition instead. |
| subscribeAsyncDisposableEvent | Subscribes to an event on an AsyncEventSource and returns an AsyncDisposableEx that unregisters it on dispose. Async counterpart of the native subscribeDisposableEvent; the event name and callback argument types are inferred from the source’s event map. |
| Type | Description |
|---|---|
| CallbackArguments | Resolves callback argument types for an event. - When EventMap has an index signature (untyped default): returns unknown[], allowing Args to be inferred freely from the callback. - When EventMap has explicit keys only (typed map): returns EventMap[EventName], enforcing the declared argument types and enabling autocomplete. |
| EventMapBase | Base event map type for untyped emitters. |