0.2.1 • Published 9 years ago

saphir v0.2.1

Weekly downloads
5
License
MIT
Repository
github
Last release
9 years ago

Saphir Build Status Coverage Status

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