saphir
v0.2.1
Published
Observable objects
Downloads
7
Maintainers
Readme
Saphir
A small library that helps to observe defined Object/Array properties.
npm install saphir
# or
bower install saphir
var observableObj = new SaphirObject(
{a: 'foo'}
);
observableObj._subscribe('a', function(newValue, oldValue) {
console.log(oldValue + ' => ' + newValue);
});
observableObj.a = 'bar';
// foo => bar
var observableArr = new SaphirArray([1, 3, 2]);
observableArr._subscribe(function(newValue) {
console.log(newValue);
});
observableArr[0] = 4;
// [4, 3, 2]
observableArr.push(1);
// [4, 2, 3, 1]
TODO
- [ ] multi subscription
- [ ] more benchmarks