We already learned how we can create an observable containing all data from the other observables, but we can also use some other operators to combine this data or choose between them instead of just propagating everything.
This operator lets you run multiple observables in parallel and propagates the last elements of each one, so this operator is perfect for implementing flow control for promises or callback operations in JavaScript, as we already discussed in this chapter.
This operator has the following signature:
Rx.Observable.forkJoin(observables);
This is a class()
method instead of an instance()
method, and it receives an arbitrary number of arguments and the last is optional:
observables
: An arbitrary number of observable sequences to be executed
Note
It can also accept a last argument to concatenate the items of the produced array, but this is not a common use case as you can easily do it using the map()
operator over the array.
The forkJoin...