Created
July 6, 2016 04:05
-
-
Save pietgeursen/f6bede269676bfb3c97acef97f1b57b1 to your computer and use it in GitHub Desktop.
Kea 2016 rx breakout
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 Rx = require('rx') | |
var slowSource = Rx.Observable.create(function(observer) { | |
var count = 0 | |
setInterval(function() { | |
observer.onNext(count++) | |
}, 1000) | |
}) | |
var fastSource = Rx.Observable.create(function(observer) { | |
var count = 0 | |
setInterval(function() { | |
observer.onNext(count++) | |
}, 300) | |
}) | |
var merged = Rx.Observable.merge(fastSource, slowSource) | |
merged.subscribe( | |
function(x) { | |
console.log('next even', x); | |
}, | |
function(err) { | |
console.log('error'); | |
}, | |
function() { | |
console.log('done'); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment