Created
September 2, 2013 20:18
-
-
Save cwharris/6416908 to your computer and use it in GitHub Desktop.
What should this be doing exactly?
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 Rx = require('rx'); | |
var a = new Rx.Subject(); | |
var b = new Rx.Subject(); | |
var c = new Rx.Subject(); | |
var resA = Rx.Observable | |
.when( | |
a.and(b) | |
.then(function (a, b) { return a + b; }) | |
); | |
resA.subscribe(function () { | |
console.log(arguments); | |
}); | |
a.onNext('0'); | |
a.onNext('1'); | |
a.onNext('2'); | |
a.onNext('3'); | |
a.onNext('4'); | |
a.onNext('5'); | |
a.onNext('6'); | |
a.onNext('7'); | |
a.onNext('8'); | |
a.onNext('9'); | |
b.onNext('0'); | |
b.onNext('1'); |
Shouldn't I only be getting one event out of this? Why is it acting exactly like zip?
What you are seeing is correct behavior. This isn't a once only operation. It's just a when either happens in any order, then produce this result. See this test for further details
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Result:
cwharris$ node app
{ '0': '00' }
{ '0': '11' }