@epikodelabs/streamix / createAsyncIterator
Function: createAsyncIterator()
createAsyncIterator<
T>(opts): () =>AsyncIterator<T,any,undefined> &object
Defined in: projects/libraries/streamix/src/lib/subjects/helpers.ts:231
Creates a factory for async iterators backed by a Subject/Stream subscription.
The iterator buffers next notifications until the consumer calls next(). It also participates in subject backpressure by returning a Promise from the receiver's next(...) that resolves when the consumer pulls the buffered value.
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
lazy?
boolean
When true, the iterator does not register with the source until the consumer actually pulls (next()/__tryNext()).
Streams should generally use lazy: true to avoid creating hidden subscriptions when an iterator is constructed but never consumed.
Subjects should generally use lazy: false so operators that eagerly emit into an internal Subject can buffer values for downstream consumers.
Returns
A function that creates a fresh AsyncIterator per call.
():
AsyncIterator<T,any,undefined> &object
Returns
AsyncIterator<T, any, undefined> & object