Skip to content

@epikodelabs/streamix


@epikodelabs/streamix / src/public-api / IterateOptions

Interface: IterateOptions ​

Defined in: projects/libraries/streamix/src/lib/atoms/iterate.ts:26

Creates an async iterable from an atom.

Yields the current value immediately, then yields subsequent values whenever the atom emits. The iterable completes when the atom is disposed.

Param ​

source

The atom or async iterable to iterate over.

Example ​

ts
const a = atom(0);
setTimeout(() => a.next(1), 10);
setTimeout(() => a.next(2), 20);
setTimeout(() => a.dispose(), 30);

for await (const value of iterate(a)) {
  console.log(value); // 0, 1, 2
}

Properties ​

replayCurrent? ​

optional replayCurrent?: boolean

Defined in: projects/libraries/streamix/src/lib/atoms/iterate.ts:32

Whether an Atom's current value should be delivered when iteration starts. Defaults to true. Internal adapters can disable this when they already captured the same current value and only need future emissions.

Released under the MIT License.