Created
January 18, 2018 21:41
-
-
Save sergzak022/1848b3318b16bb2c44e8e4f3e2213ac2 to your computer and use it in GitHub Desktop.
RxJS: Switching and Exhausting
This file contains hidden or 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$ = Observable.timer(0, 200).take(6); | |
function multBy2Delayed(number) { | |
// I take 1000ms to multiply your number by two | |
return Observable.timer(1000).map(() => number * 2); | |
} | |
// NEW CODE STARTS HERE | |
var exhausted$ = source$.exhaustMap((number) => { | |
return multBy2Delayed(number); | |
}); | |
exhausted$.subscribe((number) => { | |
console.log(number); // will log 0 and 10 to console | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment