Warm streams

So far, we have been describing and discussing cold Observables and hot Observables, but there is a third kind: the warm Observable. A warm Observable can be thought of as being created as a cold Observable, but turning into a hot Observable under certain conditions. Let's look at such a case by introducing the refCount() operator:

// hot-cold-warm/warm-observer.jsconst Rx = require("rxjs/Rx");let warmStream = Rx.Observable.interval(1000).take(3).publish().refCount();let start = new Date();setTimeout(() => {  warmStream.subscribe(data => {    console.log(`subscriber 1 - ${new Date() - start}`,data);  });}, 2000);

OK, so we started to use the operator publish(), and it looks like we are about to use our connect() operator and that ...

Get Building Large-Scale Web Applications with Angular 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.