JSFiddle - React, Tailwind, and code Playground
by bman654
HTML
<script src="http://cdn.strategiqcommerce.com/ajax/libs/rxjs/2.1.0/rx.min.js"></script>
JavaScript
var obs = {};
var aRef = Rx.Observable.defer(function () {
return obs.a;
});
var bRef = Rx.Observable.defer(function () {
return obs.b;
});
obs.a = Rx.Observable.returnValue(42).combineLatest(bRef, function (a, b) {
return a + b;
}).catchException(function (e) {
return Rx.Observable.throwException(e === true ? new Error("Invalid, possibly cyclic observables") : e);
});
obs.b = Rx.Observable.returnValue(42).combineLatest(aRef, function (b, a) {
return b + a;
}).catchException(function (e) {
return Rx.Observable.throwException(e === true ? new Error("Invalid, possibly cyclic observables") : e);
});
obs.a.subscribe(function (val) {
console.log(val);
},
function (err) {
console.error(err && err.message || err);
},
function () {
console.log("completed");
});