/* Using Observable sequences */
var source = Rx.Observable.amb(
Rx.Observable.timer(500).select(function () { return 'foo'; }),
Rx.Observable.timer(200).select(function () { return 'bar'; })
);
var subscription = source.subscribe(
function (x) { console.log('Next: ' + x); },
function (err) { console.log('Error: ' + err); },
function () { console.log('Completed'); });
/* Using Promises and Observables */
var source = Rx.Observable.amb(
RSVP.Promise.resolve('foo')
Rx.Observable.timer(200).select(function () { return 'bar'; })
);
var subscription = source.subscribe(
function (x) { console.log('Next: ' + x); },
function (err) { console.log('Error: ' + err); },
function () { console.log('Completed'); });