Created
August 26, 2011 21:53
-
-
Save mattpodwysocki/1174516 to your computer and use it in GitHub Desktop.
Joins as Promises
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
// requires rx.min.js, rx.joins.min.js | |
// Joins as promises | |
var obs1 = Rx.Observable.Return(42); | |
var obs2 = Rx.Observable.Return('foo'); | |
var obs3 = Rx.Observable.When(obs1.And(obs2).Then(function (o1, o2) { | |
return o2 + ',' + o1 | |
})); | |
obs3.Subscribe(function(x) { | |
console.log(x); // 'foo,42' | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Almost identical to jQuery Deferred.