O'Reilly logo

Mastering Reactive JavaScript by Erich de Souza Oliveira

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using the mergeAll() operator

This method is analogous to the concatAll() operator following the merge() operator rules. So it merges all observables within an observable. It has the following signature:

observable.mergeAll(); 

As you can see, it does not receive any parameter as it will merge all observables within an observable. This behavior can be seen in the following example:

Rx.Observable.of(   Rx.Observable.just(1),   Rx.Observable.fromPromise(Promise.resolve(2)),   Rx.Observable.of(3,4) ).mergeAll() .subscribe((k)=>console.log(k)); 

Now that we are using the mergeAll() operator instead of the concatAll() operator, it will follow the order of the propagated data, and as we have an Observable from a Promise, its value will be delayed ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required