O'Reilly logo
  • Zongshao Che thinks this is interesting:

This method can turn any A+ Promise into an observable.


Cover of Mastering Reactive JavaScript


We know Promise starts eagerly. While Observable starts on-demand. Wrapping a Promise to an Observable won't change the behavior of the Promise. [TestCase] const promise = new Promise(resolve => { setTimeout(() => { resolve(1); }, 1000); console.log('promise start'); });

Rx.Observable .fromPromise(promise);