Skip to content

Instantly share code, notes, and snippets.

@mbergal
Created August 9, 2018 15:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mbergal/408d1fa85709c6a20c44b8f0d4bbe3b2 to your computer and use it in GitHub Desktop.
Save mbergal/408d1fa85709c6a20c44b8f0d4bbe3b2 to your computer and use it in GitHub Desktop.
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