Skip to content

async-events

Async event emitter.

ClassDescription
AsyncEventRefDisposableAn AsyncDisposableEx that unregisters an AsyncEventRef on dispose, via the event source stored on the ref itself. Async counterpart of the native EventRefDisposable.
AsyncEventsA class that extends AsyncEventsBase and provides public methods for triggering events. This class exists as parity with obsidian#Events. But exposing publicly trigger() methods violates encapsulation. Avoid using it in favor of AsyncEventsBase.
AsyncEventsBaseAsync event source implementation.
InterfaceDescription
AsyncEventRefAsync event reference.
AsyncEventSourceAsync event emitter implementation.
AsyncEventTriggerInterface 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.
GenericAsyncEventSourceInterface for event source, used by AsyncEventRef so that refs can be stored regardless of the emitter’s EventMap.
SubscribeAsyncDisposableEventParamsParameters for subscribeAsyncDisposableEvent.
FunctionDescription
mixinAsyncEventsMixin 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.
subscribeAsyncDisposableEventSubscribes 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.
TypeDescription
CallbackArgsResolves 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.
EventMapBaseBase event map type for untyped emitters.