Watch any changes on arrays

Lets you subscribe to any changes on native JavaScript arrays.

watchArray = require('watch-array')
people = ['Joe', 'Smith']
watchArray(people, function(update){ // or watchArray.once(people, function(update){ 
    // => { 1: Taylor, 2: Brown } 
    // => [0] 
people.push('Taylor', 'Brown')
$ npm install watch-array
  • It mixes the given array with new-pubsub. So you actually have a minimalistic pub/sub API in the array.
  • It doesn't add new methods or change the behaviour of existing ones.
  • It overrides mutable methods like push, splice etc to emit the changes.