simple-watch

Trigger callbacks when objects, properties or expressions change.

npm install simple-watch
6 downloads in the last week
12 downloads in the last month

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

npm loves you