Skip to content

Instantly share code, notes, and snippets.

Created June 24, 2015 16:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/69a1a1531679e8f39aab to your computer and use it in GitHub Desktop.
Save anonymous/69a1a1531679e8f39aab to your computer and use it in GitHub Desktop.
this.$jin.value = function $jin_value( value ){
var func = function $jin_value_instance( ){
return value
}
func.valueOf = func
func.toString = func
func.$jin_value = value
return func
}
var testJinAtom = $jin.defer.callback( function (report, layerCount, done) {
function Start() {
this.prop1 = $jin.value( new $jin.atom.prop({ value: 1 }) );
this.prop2 = $jin.value( new $jin.atom.prop({ value: 2 }) );
this.prop3 = $jin.value( new $jin.atom.prop({ value: 3 }) );
this.prop4 = $jin.value( new $jin.atom.prop({ value: 4 }) );
}
function Mid(m) {this.m=m}
Mid.prototype = {
prop1 : function(){
return new $jin.atom.prop({
owner : this,
name : '_prop1',
pull: function() { return this.owner.m.prop2().get(); },
reap: function() {}
});
},
prop2 : function(){
return new $jin.atom.prop({
owner : this,
name : '_prop2',
pull: function() { return this.owner.m.prop1().get() - this.owner.m.prop3().get(); },
reap: function() {}
});
},
prop3 : function(){
return new $jin.atom.prop({
owner : this,
name : '_prop3',
pull: function() { return this.owner.m.prop2().get() + this.owner.m.prop4().get(); },
reap: function() {}
});
},
prop4 : function(){
return new $jin.atom.prop({
owner : this,
name : '_prop4',
pull: function() { return this.owner.m.prop3().get(); },
reap: function() {}
});
}
}
var start = new Start();
var layer = start;
for (var i = layerCount; i--;) {
layer = new Mid(layer);
layer.prop1().pull();
layer.prop2().pull();
layer.prop3().pull();
layer.prop4().pull();
}
var end = layer;
report.beforeChange = [
end.prop1().get(),
end.prop2().get(),
end.prop3().get(),
end.prop4().get()
];
var st = Date.now();
start.prop1().push(4);
start.prop2().push(3);
start.prop3().push(2);
start.prop4().push(1);
new $jin.defer(function() {
report.afterChange = [
end.prop1().get(),
end.prop2().get(),
end.prop3().get(),
end.prop4().get()
];
report.recalculationTime = Date.now() - st;
done();
});
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment