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 ...

Get Reactive Programming with RxJS 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.