ReferenceforkJoin
Reference · 26
forkJoin
forkJoin
Waits for all sources to complete, then emits their last values.
Signature
forkJoin([a$, b$, ...] | { a: a$, b: b$, ... }): Observable<...>
Marble diagram
a: --1---3|
b: ----2----4|
result: -----------[3,4]|
What it does
Subscribes to all sources and waits for each to complete. It emits exactly one array (or object) with each source's last value, then completes itself.
When to use
The Promise.all equivalent for several independent HTTP requests. Loading a set of reference data when a screen opens.
Gotcha
If even one source never completes, forkJoin never emits. Subjects/interval without take don't work. If one source errors, the whole forkJoin fails.
See also
combineLatest, zip, concat
script.ts
CONSOLE · Console output
Hit Run to see the result...