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
function zipStrings(str1, str2) { | |
if (str1[0] == null && str2[0] == null) { | |
return ''; | |
} | |
let ch1 = str1[0]; | |
let ch2 = str2[0]; | |
let tail = zip( |
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 exhausted$ = source$.exhaustMap((number) => { | |
return multBy2Delayed(number); | |
}); | |
// Code above will work exactly the same as code bellow | |
var exhausted$ = source$.map((number) => { | |
return multBy2Delayed(number); | |
}).exhaust(); |
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 switched$ = source$.map((number) => { | |
return multBy2Delayed(number); | |
}).switch(); | |
// Code above will work exactly the same as code bellow | |
var switched$ = source$.switchMap((number) => { | |
return multBy2Delayed(number); | |
}); |
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$ = 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) => { |
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$ = 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 switched$ = source$.switchMap((number) => { |
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
function multBy2Delayed(number) { | |
// I take 1000ms to multiply your number by two | |
return Observable.timer(1000).map(() => number * 2); | |
} |
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
// will log 0,1,2,3,4,5 to console | |
Observable.timer(0, 200).take(6).subscribe((val) => console.log(val)); |
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$ = Observable.timer(0, 200).take(6); |