@jiminp/tooltool
    Preparing search index...

    Interface AsyncChannel<Y, R, E>

    Bidirectional async channel combining AsyncSink and AsyncSource.

    Provides a write-side for pushing values and a read-side for consuming them via async iteration or event callbacks.

    declare const ch: AsyncChannel<number, string>;
    ch.next(1);
    ch.next(2);
    ch.complete("done");

    for await (const v of ch) console.log(v); // 1, 2
    console.log(await ch.result()); // "done"
    interface AsyncChannel<Y, R = void, E = unknown> {
        "[asyncIterator]"(): AsyncIterator<Y, R, any>;
        complete(...args: OptionalIfVoid<R>): void;
        error(err: E): void;
        next(y: Y): void;
        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 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.