Skip to content

@epikodelabs/streamix


@epikodelabs/streamix / forkJoin

Function: forkJoin()

Implementation signature.

Internal Remarks

This implementation supports both forkJoin(a, b, c) and forkJoin([a, b, c]).

Call Signature

forkJoin<T, R>(...sources): Stream<T[]>

Defined in: projects/libraries/streamix/src/lib/streams/forkJoin.ts:25

Waits for all sources to complete and emits an array of their last values.

This is similar to RxJS forkJoin:

  • Each source is consumed fully.
  • The output emits exactly once (an array of the last value from each source) and then completes.
  • If any source errors, the output errors.
  • If any source completes without emitting a value, forkJoin errors.

Sources may be Streams or plain values (including promises). Plain values are converted to streams via fromAny(...).

Type Parameters

T

T = any

The type of the last values emitted by each stream.

R

R extends readonly unknown[] = any[]

Parameters

sources

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

Streams or values (including promises) to join.

Returns

Stream<T[]>

A stream that emits a single array of last values.

Example

ts
const s = forkJoin(from([1, 2]), from([10]));
// emits: [2, 10]

Call Signature

forkJoin<T, R>(sources): Stream<T[]>

Defined in: projects/libraries/streamix/src/lib/streams/forkJoin.ts:37

Overload that accepts an array/tuple of sources.

Type Parameters

T

T = any

R

R extends readonly unknown[] = any[]

Parameters

sources

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

Tuple/array of sources.

Returns

Stream<T[]>

A stream that emits a single array of last values.

Released under the MIT License.