npm stats
  • Search
  • About
  • Repo
  • Sponsor
  • more
    • Search
    • About
    • Repo
    • Sponsor

Made by Antonio Ramirez

simple-watch

0.0.4

@timoxley

npmRepoSnykSocket
Downloads:2
$ npm install simple-watch
DailyWeeklyMonthlyYearly

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