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, 2console.log(await ch.result()); // "done" Copy
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, 2console.log(await ch.result()); // "done"
Yielded value type.
Return value type.
Error type (default: unknown).
unknown
Completes the channel with a return value.
The argument is optional when R is void or undefined.
R
void
undefined
Terminates the channel with an error.
Pushes a yielded value into the channel.
Subscribes to the return value only.
Subscribes to thrown errors only.
Subscribes to yielded values only.
Returns a promise that resolves with the channel's return value, or rejects with its error.
Subscribes to all events (yield, return, and throw) as they arrive.
Immediately flushes any already-buffered events to callback, then continues to deliver new events in order.
callback
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.
Example