Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

frompromise rxjs example

import { of, from } from 'rxjs';
import { mergeMap } from 'rxjs/operators';

...

//emit 'Hello'
const source = from(new Promise(resolve => resolve('Hello')));
//map to inner observable and flatten
const example = source.pipe(mergeMap(val => of(`${val} World!`)));
//output: 'Hello World!'
const subscribe = example.subscribe(val => console.log(val));
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #frompromise #rxjs
ADD COMMENT
Topic
Name
6+6 =