Skip to content
Create a gist now

Instantly share code, notes, and snippets.

Embed URL


Subversion checkout URL

You can clone with
Download ZIP
Joins as Promises
// 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'

Almost identical to jQuery Deferred.

var def1 = $.Deferred().resolve(42);
var def2 = $.Deferred().resolve('foo');

var def3 = $.when(def1, def2).pipe(function(o1, o2) {
    return o2 + ',' + o1;

def3.done(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
Something went wrong with that request. Please try again.