Created
August 9, 2018 15:58
-
-
Save mbergal/408d1fa85709c6a20c44b8f0d4bbe3b2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { of, from } from 'rxjs'; | |
import { switchMap, finalize, map } from 'rxjs/operators'; | |
//emit (1,2,3,4,5) | |
const source = from([1, 2, 3, 4, 5]); | |
//add 10 to each value | |
const example = source.pipe( | |
map(val => of(val).pipe( finalize(x=>console.log('final ' + val)))), | |
switchMap(val=>val) | |
); | |
//output: 11,12,13,14,15 | |
const subscribe = example.subscribe(val => console.log(val)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment