An Observable that explicitly supports asynchronous observers.

interface AsyncObservable<T, R> {
    isAsync: true;
    isObserved: boolean;
    [asyncIterator](): AsyncIterator<T[0], any, any>;
    [dispose](): void;
    emit(...args: T): undefined | MaybePromise<R>;
    isObservedBy(observer: Observer<T, MaybePromise<R>>): boolean;
    off(observer: Observer<T, MaybePromise<R>>): void;
    on(observer: Observer<T, MaybePromise<R>>): void;
    once(observer: Observer<T, MaybePromise<R>>): void;
}

Type Parameters

  • T extends any[] = any[]
  • R = void

Hierarchy (view full)

Properties

isAsync

This flag indicates whether the observable is asynchronous. Any observable that accepts promise returns may be asynchronous but this information is not available at runtime unless you specify here, typically via AsyncObservable.

isObserved: boolean

True if there is at least one observer registered.

Methods

  • Observable supports standard "for await (const value of observable").

    Using an observer in this manner limits your listener to the first parameter normally emitted and your observer cannot return a value.

    Returns AsyncIterator<T[0], any, any>