Skip to content

@epikodelabs/streamix


@epikodelabs/streamix / withLatestFrom

Function: withLatestFrom()

Implementation signature.

Internal Remarks

Supports both withLatestFrom(a, b, c) and withLatestFrom([a, b, c]).

Call Signature

withLatestFrom<T, R>(...streams): Operator<T, [T, ...R[]]>

Defined in: projects/libraries/streamix/src/lib/operators/withLatestFrom.ts:24

Creates a stream operator that combines the source stream with the latest values from other provided streams.

This operator is useful for merging a "trigger" stream with "state" streams. It waits for a value from the source stream and, when one arrives, it emits a tuple containing that source value along with the most recently emitted value from each of the other streams.

The operator is "gated" and will not emit any values until all provided streams have emitted at least one value. Inputs may be streams or values (including promises).

Type Parameters

T

T = any

The type of the values in the source stream.

R

R extends readonly unknown[] = any[]

The tuple type of the values from the other streams (e.g., [R1, R2, R3]).

Parameters

streams

...{ [K in string | number | symbol]: Stream<R[K<K>]> | MaybePromise<R[K<K>]> }

Streams or values (including promises) to combine with the source stream.

Returns

Operator<T, [T, ...R[]]>

An Operator instance that can be used in a stream's pipe method. The output stream emits tuples of [T, ...R].

Call Signature

withLatestFrom<T, R>(streams): Operator<T, [T, ...R[]]>

Defined in: projects/libraries/streamix/src/lib/operators/withLatestFrom.ts:36

Overload that accepts an array/tuple of auxiliary sources.

Type Parameters

T

T = any

R

R extends readonly unknown[] = any[]

Parameters

streams

{ [K in string | number | symbol]: Stream<R[K<K>]> | MaybePromise<R[K<K>]> }

Tuple/array of auxiliary sources.

Returns

Operator<T, [T, ...R[]]>

An operator that emits [sourceValue, ...latestAuxValues].

Released under the MIT License.