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

Adding operators to observables

In Chapter 2, Reacting for the First Time, we used operators using bacon.js. They let us transform our data before it reaches the subscribers of the given Observable. The operators in RxJS work similar to the ones in bacon.js; some even have the same name. They are just methods called from Observable objects, as you can see in the following example:

Rx.Observable   .just('Hello ')   .map((msg)=>msg+'World')   .subscribe((msg)=> console.log(msg)); 

In this example, we created an Observable, which emits only one string, and called the map() operator over this Observable and subscribed to it to show the result in the console:

    Hello World
If you can't recall the map() operator from Chapter 2, Reacting for the ...

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