Skip to content

Instantly share code, notes, and snippets.

@Ibro
Created April 29, 2017 03:06
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 Ibro/6a997496b5a09eb7fb1c92683a9acc5d to your computer and use it in GitHub Desktop.
Save Ibro/6a997496b5a09eb7fb1c92683a9acc5d to your computer and use it in GitHub Desktop.
RxJS - Observeable in flatMap function - Coding Blast - www.codingblast.com
import {Observable} from 'rxjs';
let source = Observable
.interval(100) // interval starts from 0
.take(5) // take first 5
// 0, 1, 2, 3, 4
.flatMap(n => {
let observable = Observable.of(n + 10);
// we now have an observable here, not a number!
return observable;
});
source.subscribe((value) => {
console.log('in next. Value: ', value);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment