Skip to content

combine

Combine two observables with a map function and an optional pre-treatment.

Note: you can use the pre-treatment to add a filter, a distinctUntilChanged, any other operator that can be used in a pipe, or even an UntilDestroy operator.

Available since v1.0.0

import { combine } from '@helpers4/observable';
combine<T, U, R>(source1: Observable<T>, source2: Observable<U>, map: function, options?: combineOptions<T, U>): Observable<R>
ParameterTypeDescription
source1Observable<T>first source of data
source2Observable<U>second source of data
mapfunctionway to combine data
optionscombineOptions<T, U>options for the combineLatest operator (optional)

Observable<R> — an observable that emits the result of the map function

Combines the latest values of two observables using a mapping function.

combine(of(1), of(2), ([a, b]) => a + b)
// emits 3

View source on GitHub