immutable-model-object
v0.0.0
Published
Simple usage of JavaScript objcets as models with callbacks for computed properties.
Downloads
4
Readme
Model-Object
A way to set and get on objects using string and dot notation for keys. Can set calculated properties that are run on every set.
var data = {},
model = Model(data);
model.calculations({
'user.name.full' : function() {
return [this.get('user.name.first'), this.get('user.name.last')].join(' ').trim();
}
});
model.set('user.name.first', 'Fran');
model.set('user.name.last', 'Stan');
model.get('user.name.full').should.equal('Fran Stan');
data.user.name.full.should.equal('Fran Stan');