combineLatestAll
function
stable
Flattens an Observable-of-Observables by applying combineLatest
when the Observable-of-Observables completes.
combineLatestAll<R>(project?: (...values: any[]) => R)
Parameters
project | Optional. Default is optional 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. |
Description
combineLatestAll
takes an Observable of Observables, and collects all Observables from it. Once the outer Observable completes, it subscribes to all collected Observables and combines their values using the combineLatest
strategy, such that:
- Every time an inner Observable emits, the output Observable emits
- When the returned observable emits, it emits all of the latest values by:
- If a
project
function is provided, it is called with each recent value from each inner Observable in whatever order they arrived, and the result of theproject
function is what is emitted by the output Observable. - If there is no
project
function, an array of all the most recent values is emitted by the output Observable.
- If a
Examples
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));
Overloads
combineLatestAll(): OperatorFunction<ObservableInput<T>, T[]>
Parameters
There are no parameters.
Returns
OperatorFunction<ObservableInput<T>, T[]>
combineLatestAll(): OperatorFunction<any, T[]>
Parameters
There are no parameters.
Returns
OperatorFunction<any, T[]>
combineLatestAll(project: (...values: T[]) => R): OperatorFunction<ObservableInput<T>, R>
Parameters
project | Type: |
Returns
OperatorFunction<ObservableInput<T>, R>
combineLatestAll(project: (...values: any[]) => R): OperatorFunction<any, R>
Parameters
project | Type: |
Returns
OperatorFunction<any, R>
See Also
© 2015–2021 Google, Inc., Netflix, Inc., Microsoft Corp. and contributors.
Code licensed under an Apache-2.0 License. Documentation licensed under CC BY 4.0.
https://rxjs.dev/api/operators/combineLatestAll