Skip to content
Fire callbacks when objects or expressions change
JavaScript CSS
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
test
.gitignore
.travis.yml
History.md
Makefile
Readme.md
component.json
index.js
package.json

Readme.md

simple watch

Fires events when objects change.

Build Status

Installation

$ component install timoxley/simple-watch

Examples

Watch object properties

var watch = require('simple-watch')()

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

Something went wrong with that request. Please try again.