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 merge() operator

In the last section, we learned to use the concat() operator to concatenate observables keeping the order of each observable from left to right.  We also saw that if one of the observables is infinite, the other observables after this will never propagate this data. When we want to concatenate observables preserving the order of the data instead of the order of the observable, we use the merge() operator.

This operator has the following signature:

observable.merge(observable); 

It accepts any number of arguments, but they all must be observables:

  • observable: This is the other observable to be merged
There is another signature for this method where you can set the maximum number of observables being subscribed ...

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