@epikodelabs/streamix / createAsyncIterator
Function: createAsyncIterator()
createAsyncIterator<
T>(opts): () =>AsyncIterator<T,any,any> &object
Defined in: projects/libraries/streamix/src/lib/utils/iterator.ts:35
Creates a factory that produces fresh AsyncIterator instances backed by an internal queue with producer-backpressure.
The register callback receives a Receiver<T> whose next()/complete()/ error() methods push into the iterator's queue. next() returns a Promise<void> (or void) â€" the promise acts as a backpressure signal from the consumer: it resolves only when the consumer pulls the value with next() or __tryNext().
Each call of the returned factory function creates an independent iterator with its own buffer and subscription.
When lazy: true, registration is deferred until the consumer actually pulls (either next() or __tryNext>), which avoids hidden subscriptions for iterators that are constructed but never consumed.
Type Parameters
T
T
Value type.
Parameters
opts
Registration function and lazy mode.
register
(receiver) => Subscription
Returns
A function that creates a fresh AsyncIterator per call.
():
AsyncIterator<T,any,any> &object
Returns
AsyncIterator<T, any, any> & object