Skip to content

@mattpodwysocki /joins-rx.js
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
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'
});
@gradbot

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.