ReferencecombineLatest
Reference · 25
combineLatest
combineLatest
Emits an array of the latest values from all inputs on any change.
Signature
combineLatest([a$, b$, ...]): Observable<[A, B, ...]>
Marble diagram
a: --1---3----|
b: ----2---4--|
result: ----[1,2]-[3,2]-[3,4]-|
What it does
Subscribes to all sources and waits for the first next from each. After that, on any update from any source, it emits an array of their latest values. It completes when all sources complete.
When to use
Merging state: combineLatest([filter$, sort$, page$]) → the resulting view model. Dashboards, forms with dependent fields.
Gotcha
If even one source never emits a first value, combineLatest never emits. Often fixed with startWith.
See also
forkJoin, withLatestFrom, zip
script.ts
CONSOLE · Console output
Hit Run to see the result...