Skip to content

combineLatest

Combines multiple Observables to create an Observable whose values are calculated from the latest values of each of its input Observables.

This method relies on combineLatestOperator of rxjs.

The main difference with combineLatestOperator is in case of empty parameters. If the parameter is empty (empty array or empty object), the result will be also empty.

ATTENTION: this version doesn’t support scheduler nor mapper as last argument like in combineLatestOperator.

Available since v1.0.0

import { combineLatest } from '@helpers4/observable';
combineLatest<A extends readonly unknown[]>(sources: readonly [ObservableInputTuple<A>]): Observable<A>
ParameterTypeDescription
sourcesreadonly [ObservableInputTuple<A>]

Observable<A> —

Combines an array of observables into one that emits arrays of their latest values.

combineLatest([of(1), of(2), of(3)])
// emits [1, 2, 3]

Returns an observable that emits an empty array when given no sources.

combineLatest([])
// emits []

View source on GitHub