ForkJoin
Last updated
Was this helpful?
Last updated
Was this helpful?
Accepts an Array of ObservableInput or a dictionary Object of ObservableInput and returns an Observable that emits either an array of values in the exact same order as the passed array, or a dictionary of values in the same shape as the passed dictionary.
forkJoin
is an operator that takes any number of input observables which can be passed either as an array or a dictionary of input observables. If no input observables are provided, resulting stream will complete immediately.
forkJoin
will wait for all passed observables to complete and then it will emit an array or an object with last values from corresponding observables.
If you pass an array of n
observables to the operator, resulting array will have n
values, where first value is the last thing emitted by the first observable, second value is the last thing emitted by the second observable and so on.
If you pass a dictionary of observables to the operator, resulting objects will have the same keys as the dictionary passed, with their last values they've emitted located at the corresponding key.
That means forkJoin
will not emit more than once and it will complete after that. If you need to emit combined values not only at the end of lifecycle of passed observables, but also throughout it, try out combineLatest
or zip
instead.