The concat() and merge() operators
With retry()
and retryWhen()
we've stumbled upon operators that take as parameters other Observables and work with their emissions. Combining multiple Observables into a single chain is a common practice mostly in RxJS due to the asynchronous nature of JavaScript by design. In RxPHP we don't use them as often, but it's worth having a quick look at them.
The merge() operator
In order to merge two Observables into a single one that emits all values from both of them (including onError
signals) we can use the merge()
operator.
Marble diagram representing the merge() operator, from http://reactivex.io/rxjs/class/es6/Observable.js~Observable.html#static-method-merge
As we can see from the marble diagram, this operator reemits values from source and the merged Observables. This means it subscribes to both of them and emits values as they arrive.
To better understand how it works, we can make a simple example with two interval Observables where...