Simplest JS Model with listeners
oModel is a work in progress, with no public release yet.
Build a super simple js model that allows for onChange call backs.
Create a new model (without any attributes)
var person = new Model();
or with attributes / properties
var person = new Model({
name: 'oscar'
});Set / Update attributes
person.set('age', 25);
person.update('name', 'george');update is an alias for set
Listen to models
var callback = function(attributes) {
console.log(attributes);
}
person.onChange(callback);OnChange
person.update('name', 'edward');
// callback log
// {name: 'edward', age: 25}