@jiminp/tooltool
    Preparing search index...

    Interface AsyncSource<Y, R, E>

    Read-side of an async channel that consumes values via iteration or callbacks.

    Implements AsyncIterable, so it can be consumed with for await...of. Each iterator returned by [Symbol.asyncIterator]() replays from the beginning of the buffered events independently.

    declare const source: AsyncSource<number, string>;

    for await (const v of source) console.log(v);
    console.log(await source.result());
    interface AsyncSource<Y, R = void, E = unknown> {
        "[asyncIterator]"(): AsyncIterator<Y, R, any>;
        onReturn(callback: (ret: R) => void): void;
        onThrow(callback: (err: E) => void): void;
        onYield(callback: (y: Y) => void): void;
        result(): Promise<R>;
        subscribe(callback: (event: AsyncEvent<Y, R, E>) => void): void;
    }

    Type Parameters

    • Y

      Yielded value type.

    • R = void

      Return value type.

    • E = unknown

      Error type (default: unknown).

    Hierarchy (View Summary)

    Index

    Methods

    • Returns AsyncIterator<Y, R, any>

    • Subscribes to the return value only.

      Parameters

      • callback: (ret: R) => void

      Returns void

    • Subscribes to thrown errors only.

      Parameters

      • callback: (err: E) => void

      Returns void

    • Returns a promise that resolves with the channel's return value, or rejects with its error.

      Returns Promise<R>

    • Subscribes to all events (yield, return, and throw) as they arrive.

      Parameters

      Returns void

      Immediately flushes any already-buffered events to callback, then continues to deliver new events in order.