skip to content

forkJoin

 

forkJoin creates an Observable from multiple Observables.
Resulting stream waits for all input streams to complete, then combines and emits their latest values

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
const { rxObserver } = require('api/v0.3');
const { timer, forkJoin } = require('rxjs');
const { mapTo, take } = require('rxjs/operators');


const a$ = timer(10).pipe(mapTo('a'));
const b$ = timer(5, 5).pipe(take(3));

const result$ = forkJoin([ a$, b$ ]);

a$.subscribe(rxObserver('a$'));
b$.subscribe(rxObserver('b$'));
result$.subscribe(rxObserver('forkJoin(a$, b$)'));

0msa$startcompleteaa b$startcomplete00 11 22 forkJoin(a$, b$)startcomplete[a,2][a,2]