RxJS - Join Operator forkJoin



This operator will take in an array or dict object as an input and will wait for the observable to complete and return the last values emitted from the given observable.

Syntax

forkJoin(value: array or dict object): Observable

Parameters

value − The value is the input which can be an array or dict object.

Return value

An observable is returned with last values emitted from the given observable.

Example

import { of, forkJoin } from 'rxjs';
import { concat } from 'rxjs/operators';

let list1 = of(2, 3, 4, 5, 6);
let list2 = of(4, 9, 16, 25, 36)
let final_val = forkJoin([list1, list2]);
final_val.subscribe(x => console.log(x));

Output

[6,36]
Advertisements