skip to content

fromPromise

 

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

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

const promise = new Promise((resolve, reject)=>{
  setTimeout(() => resolve('done'), 10);
});

from(promise)
  .subscribe(rxObserver('from(promise)'));

0msfrom(promise)start

Also check this from iterable example