Creates an async channel that buffers values and replays them to each iterator.
Yielded value type.
Return value type.
Thrown error type (default: unknown).
unknown
An AsyncChannel.
Each call to [Symbol.asyncIterator]() returns a fresh iterator starting from the first buffered value. Calling result() multiple times returns the same promise without affecting iteration.
[Symbol.asyncIterator]()
result()
const ch = createAsyncChannel<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
const ch = createAsyncChannel<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"
Creates an async channel that buffers values and replays them to each iterator.