@epikodelabs/streamix / delayWhile
Function: delayWhile()
delayWhile<
T>(predicate):Operator<T,T>
Defined in: projects/libraries/streamix/src/lib/operators/delayWhile.ts:31
Buffers values while a predicate returns true and releases them once the predicate flips to false.
This operator evaluates the provided predicate for every value coming from the source stream.
- When the predicate resolves to
true, the value is held in an internal queue. - Once the predicate returns
falsefor the first time, all buffered values are flushed in order, including the current value, and the operator resumes emitting immediately. - The operator can re-enter the buffering state later if the predicate becomes
trueagain. - When the source completes while values are buffered, those values are flushed before completing.
The predicate is allowed to return either a boolean or a promise of a boolean.
Type Parameters
T
T = any
The type of values flowing through the stream.
Parameters
predicate
(value, index) => MaybePromise<boolean>
Function to test each value. Receives the value and its index; true means delay, false means emit immediately.
Returns
Operator<T, T>