Creating reusable operators with let()

The let() operator lets you have the whole operator and operate on it, rather than just manipulating the values as you would do with the map() operator, for example. Using the let() operator could look like this:

import Rx from "rxjs/Rx";let stream = Rx.Observable.of(0,1,2);let addAndFilter = obs => obs.map( x => x * 10).filter(x => x % 10 === 0);let sub3 = obs => obs.map(x => x - 3);stream  .let(addAndFilter)  .let(sub3)  .subscribe(x => console.log('let', x));

In the preceding example, we were able to define a group of operators such as addAndFilter and sub3 and use them on the stream with the let() operator. This enables us to create composable and reusable operators. It is with this very knowledge that ...

Get Architecting Angular Applications with Redux, RxJS, and NgRx now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.