Created
December 8, 2016 21:38
-
-
Save ashish173/79f15f678b089b7f194c4d78a0935d14 to your computer and use it in GitHub Desktop.
FlatMap
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
var source = Rx.Observable | |
.range(1, 2) | |
.flatMap(function (x) { | |
return Rx.Observable.range(x, 2); | |
}); | |
var subscription = source.subscribe( | |
function (x) { console.log('Next: ' + x); }, | |
function (err) { console.log('Error: ' + err); }, | |
function () { console.log('Completed'); }); | |
// Next: 1, 2, 2, 3 | |
// when 1 from outer observable is passed in it results into 1, 2 | |
// when 2 from outer observable is passed in it results into 2, 3 | |
// All the results matter here from the source unlike switchMap. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment