Adding operators

We have come a long way in defining our own core implementation of RxJS, but we are missing an important piece of the puzzle—operators. Operators are the real power of RxJS and can be seen as a utility method that allows us to manipulate our stream with ease. Let's select filter() as the target of our example. A filter operator is a method that you can call on the stream. The idea is to provide it with a function that is able to determine, value for value, whether the specific value in question should be emitted. A typical use case looks like the following:

let stream$ = Observable.of(1,2,3)  .filter( x => x > 1 );stream$.subscribe( data => console.log(data)) // will emit 2,3

In the preceding code, we can see that the function ...

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.