from

RxJS 5 from

by Mike Lin

HTML

<script src="https://npmcdn.com/@reactivex/[email protected]/dist/global/Rx.umd.js"></script>

JavaScript

//emit array as a sequence of values
const arraySource = Rx.Observable.from([1,2,3,4,5]);
//output: 1,2,3,4,5
const subscribe = arraySource.subscribe(val => console.log(val));

const promiseSource = Rx.Observable.from(new Promise(resolve => resolve('hello world')))

const subscribe1 = promiseSource.subscribe(val => console.log(val))

const map = new Map();
map.set(1, 'Hi');
map.set(2, 'Bye');

const mapSource = Rx.Observable.from(map)

const subscribe2 = mapSource.subscribe(val => console.log(val))

const stringSource = Rx.Observable.from('Hello World')

const subscribe3 = stringSource.subscribe(val => console.log(val))