Skip to content

Latest commit

History

51 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Object._watch

Object property watching using ECMAScript 5

Object.prototype.watch is a coming feature of ECMAScript 6.

But why wait?

##How to Use

###Local Watching

var w = new Watchable({a: 1});
console.log( w.a ); // Logs: 1
w._watch('a', function(property, oldValue, newValue){
console.log(property, oldValue, newValue);
});
w.a = 'test'; // Logs: a 1 'test' / Returns: 'test'
w._unwatch('a');
w.a = 'test2'; // Returns: 'test2'

###Remote Watching

var o = {x: 1};
var w = new Watchable();
w._watch('x', function(property, oldValue, newValue){
console.log(property, oldValue, newValue);
}, null, o); // Note the 4th parameter
o.x = 2; // Logs: x 1 2 / Returns: 2

About

Object.watch implementation using ECMAScript 5. Boom.

Resources

Stars

4 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages