Created
May 19, 2017 16:00
-
-
Save recuraki/cbc0093a80d618670363363a195ac2fa to your computer and use it in GitHub Desktop.
fizzbuzz.js
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
// need rx.all.js | |
let source = Rx.Observable.range(1, 100); | |
let hot = source.publish(); | |
hot.where(function (c) { | |
return c % 3 === 0; | |
}).subscribe(function (e) { | |
console.log("Fizz") | |
}) | |
hot.where(function (c) { | |
return c % 5 === 0 | |
}).subscribe(function (e) { | |
console.log("Buzz") | |
}) | |
hot.where(function (c) { | |
return (c % 3 !== 0) && (c % 5 !== 0) | |
}).subscribe(function (e) { | |
console.log(e) | |
}) | |
hot.connect(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment