Comparing version 0.3.8 to 0.3.10
@@ -27,3 +27,3 @@ // Generated by CoffeeScript 1.6.2 | ||
this._set = field.options.set || function() {}; | ||
this._bind = (field.options.bind || []).join(", "); | ||
this._bind = field.options.bind; | ||
} | ||
@@ -36,3 +36,3 @@ | ||
VirtualMapper.prototype.prepareModel = function(model, data) { | ||
var ignoreChange, onChange, onFieldChange, | ||
var ignoreChange, onChange, onFieldChange, prop, _i, _len, _ref, | ||
_this = this; | ||
@@ -52,4 +52,9 @@ | ||
}; | ||
model.bind(this._bind).delay(0).to(onChange).now(); | ||
return model.bind(this.field.path).delay(0).to(onFieldChange).now(); | ||
_ref = this._bind; | ||
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
prop = _ref[_i]; | ||
model.bind(prop).to(onChange); | ||
} | ||
onChange(); | ||
return model.bind(this.field.path).delay(-1).to(onFieldChange); | ||
}; | ||
@@ -56,0 +61,0 @@ |
@@ -51,3 +51,3 @@ // Generated by CoffeeScript 1.6.2 | ||
DataMapFieldController.prototype.prepareModel = function(model, data) { | ||
var mapper, _i, _len, _ref1, | ||
var mapper, _i, _len, _ref1, _results, | ||
_this = this; | ||
@@ -71,8 +71,10 @@ | ||
}; | ||
model.reset(data); | ||
_ref1 = this._decorators; | ||
_results = []; | ||
for (_i = 0, _len = _ref1.length; _i < _len; _i++) { | ||
mapper = _ref1[_i]; | ||
mapper.prepareModel(model, data); | ||
_results.push(mapper.prepareModel(model, data)); | ||
} | ||
return model.reset(data); | ||
return _results; | ||
}; | ||
@@ -79,0 +81,0 @@ |
@@ -35,3 +35,3 @@ // Generated by CoffeeScript 1.6.2 | ||
InheritTransport.prototype.watching = function(options) { | ||
if (options.model.get(options.property)) { | ||
if (options.model.get(options.property) != null) { | ||
return; | ||
@@ -38,0 +38,0 @@ } |
{ | ||
"name": "linen", | ||
"version": "0.3.8", | ||
"version": "0.3.10", | ||
"description": "Linen (line-in) maps API's to [bindable](/classdojo/bindable.js) `objects`, and `collections`. At [classdojo](http://classdojo.com), we use `linen` to abstract our API from front-end, so we don't necessarily depend on any sort of API while developing new components. This allows us to rapidly build prototypes which can be wired up later.", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
@@ -23,10 +23,24 @@ var linen = require("../.."), | ||
/*it("can bind two properties together", function(next) { | ||
it("can get a virtual field", function() { | ||
var m = s.model({ firstName: "Craig", lastName: "Condon" }) | ||
setTimeout(function() { | ||
console.log(m.data) | ||
next(); | ||
}, 2); | ||
expect(m.get("firstName")).to.be("Craig"); | ||
expect(m.get("lastName")).to.be("Condon"); | ||
expect(m.get("fullName")).to.be("Craig Condon"); | ||
}); | ||
})*/ | ||
it("can set a virtual field", function() { | ||
var m = s.model({ firstName: "Craig", lastName: "Condon" }); | ||
m.set("fullName", "A B"); | ||
expect(m.get("firstName")).to.be("A"); | ||
expect(m.get("lastName")).to.be("B"); | ||
expect(m.get("fullName")).to.be("A B"); | ||
}); | ||
it("listens when either bindings change", function() { | ||
var m = s.model({ firstName: "Craig", lastName: "Condon" }); | ||
m.set("firstName", "AA"); | ||
expect(m.get("fullName")).to.be("AA Condon"); | ||
m.set("lastName", "BB"); | ||
expect(m.get("fullName")).to.be("AA BB"); | ||
}) | ||
}); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
102186
2510