Efficient-angular
GitHubToggle Dark/Light/Auto modeToggle Dark/Light/Auto modeToggle Dark/Light/Auto modeBack to homepage

combineLatestAll

Flattens an Observable-of-Observables by applying combineLatest when the Observable-of-Observables completes.

Syntax

combineLatestAll<R>(project?: (...values: any[]) => R)
ParametersDescription
project OptionalDefault is undefined. Function to map the most recent values from each inner Observable into a new result. Takes each of the most recent values from each collected inner Observable as arguments, in order.

Example

Map two click events to a finite interval Observable, then apply combineLatestAll

import { fromEvent, interval } from 'rxjs';
import { map, combineLatestAll, take } from 'rxjs/operators';
 
const clicks = fromEvent(document, 'click');
const higherOrder = clicks.pipe(
  map(ev =>
     interval(Math.random() * 2000).pipe(take(3))
  ),
  take(2)
);
const result = higherOrder.pipe(
  combineLatestAll()
);
 
result.subscribe(x => console.log(x));