O'Reilly logo

Developing an Angular 2 Edge by Ran Wahle, Mary Gualtieri, Wojciech Kwiatek, Suguru Inatomi, Filip Lauc, Troy Mott

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

Chapter 11. RxJS

You probably have met RxJS before while playing with Angular 2. The whole idea of change detection and notifying components is based on Observables. This nothing new, in fact, it is about to be part of JavaScript in a future release. Despite this, we can use libraries that mimic this behavior. One of them is RxJS.

What is Observable?

Let’s consider a JS generator for a while.

function* returnManyValuesGenerator() {
  yield 1;
  yield 2;
  yield 3;
}

const iterator = returnManyValuesGenerator();
console.log(iterator.next().value); // prints 1
console.log(iterator.next().value); // prints 2
console.log(iterator.next().value); // prints 3

But what if we want to add some asynchronous stuff into that, like setTimeout? It would end up ...

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