0.0.4 • Published 11 years ago
simple-watch v0.0.4
simple watch
Fires events when objects change.
Installation
$ component install timoxley/simple-watch
Examples
Watch object properties
var user = {name: 'Tim', age: 27}
watch(user, 'name', function(current, previous) {
console.log('Name was '+ previous +'. Name is now '+ current +'.')
})
user.name = 'Tim Oxley'
// => Name was Tim. Name is now Tim Oxley
Watch expressions
var user = {name: 'Tim', age: 27}
watch(user, 'age > 27', function() {
console.log(user.name ' is now ' + user.age)
})
user.age++
// => Tim is now 28
License
MIT