Purity and the Observable Pipeline
An Observable pipeline is a group of operators chained together, where each one takes an Observable as input and returns an Observable as output. We’ve been using pipelines in this book; they are ubiquitous when programming with RxJS. Here’s a simple one:
| | Rx.Observable |
| | .from([1, 2, 3, 4, 5, 6, 7, 8]) |
| | .filter(function(val) { return val % 2; }) |
| | .map(function(val) { return val * 10; }); |
Pipelines are self-contained. All state flows from one operator to the next, without the need for any external variables. But as we build our reactive programs, we may be tempted to store state outside the Observable pipeline (we talked about external state in Side Effects and External ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access