Testing ForkJoinObservable
Now we can have a look at a slightly more complicated example. In RxPHP, there's an interesting operator called forkJoin()
. This operator takes as its parameter an array of Observables, collects the last value emitted for each of them, and when they all complete, emits a single array with the last values for each Observable.
This will make better sense when we look at the following marble diagram for forkJoin()
operator in RxJS:
Marble diagram representing the forkJoin() operator in RxJS (http://reactivex.io/documentation/operators/zip.html)
We're going to implement a simplified version of the forkJoin()
operator as an Observable. To make it extra clear what it does, we'll start with an example:
// fork_join_test_01.php use Rx\Observable; (new ForkJoinObservable([ Observable::fromArray([1, 2, 3, 4]), Observable::fromArray([7, 6, 5]), Observable::fromArray(['a', 'b', 'c']), ]))->subscribeCallback(function(...