JSFiddle - React, Tailwind, and code Playground
by Jagi
JavaScript
outerComp1 = null;
innerComp1 = null;
dict = {
_dep: new Deps.Dependency(),
_value: null,
set: function (v) {
if (this._value !== v) {
for (var id in this._dep._dependentsById) {
this._dep._dependentsById[id].invalidate();
}
// this._dep.changed();
}
this._value = v;
},
get: function () {
var comp = Deps.currentComputation;
this._dep._dependentsById[comp._id] = comp;
// this._dep.depend();
return this._value;
}
};
outerComp1 = Deps.autorun(function (outerComp2) {
console.log('Outer ' + dict.get(), outerComp2);
innerComp1 = Deps.autorun(function (innerComp2) {
console.log('Inner ' + dict.get(), innerComp2);
});
});