Skip to content

Instantly share code, notes, and snippets.

@recuraki
Created May 19, 2017 16:00
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 recuraki/cbc0093a80d618670363363a195ac2fa to your computer and use it in GitHub Desktop.
Save recuraki/cbc0093a80d618670363363a195ac2fa to your computer and use it in GitHub Desktop.
fizzbuzz.js
// 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