skip to content

from

 

Function from will turn an iterable, Promise, or Observable-like value into an Observable. Examples using iterable:

A stream from an Array

1
2
3
4
5
6
7
const { rxObserver } = require('api/v0.3');
const { from } = require('rxjs');

from([ 5, 10, 20 ])
  .subscribe(rxObserver('from([5, 10, 20])'));

0msfrom([5, 10, 20])startcomplete55 1010 2020

A stream from a String

1
2
3
4
5
6
7
const { rxObserver } = require('api/v0.3');
const { from } = require('rxjs');

from('Hello')
  .subscribe(rxObserver(`from('Hello')`));

0msfrom('Hello')startcompleteHH ee ll ll oo

For promise conversion example see fromPromise