March 2018
Intermediate to advanced
364 pages
8h 21m
English
This operator can take arrays or a Promise as input and turn them into a stream. To use it, simply call it like this:
// creation-operators/from.jsconst promiseStream$ = Rx.Observable.from( new Promise(resolve => setTimeout(() => resolve("data"),3000)));const arrayStream$ = Rx.Observable.from([1, 2, 3, 4]);promiseStream$.subscribe(data => console.log("data", data));// emits data after 3 secondsarrayStream$.subscribe(data => console.log(data));// emits 1, 2, 3, 4
This saves us a lot of headache by not having to deal with different types of asynchronous calls.
Read now
Unlock full access