@epikodelabs/streamix / src/public-api / loop
Function: loop()
loop<
T>(initialValue,condition,iterateFn):Atom<T>
Defined in: projects/libraries/streamix/src/lib/factories/loop.ts:19
Creates an atom that emits values in a loop based on a condition and an iteration function.
This operator is useful for generating a sequence of values until a specific condition is no longer met. It starts with an initialValue and, for each iteration, it yields the current value and then uses iterateFn to calculate the next value in the sequence.
Type Parameters
T
T = any
The type of the values in the atom.
Parameters
initialValue
MaybePromise<T>
The starting value for the loop.
condition
(value) => MaybePromise<boolean>
A function that returns true to continue the loop and false to stop.
iterateFn
(value) => MaybePromise<T>
A function that returns the next value in the sequence.
Returns
Atom<T>
An atom that emits the generated sequence of values.