Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Objects that you can subscribe to changes.
JavaScript
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
.gitignore
.npmignore
.travis.yml
README.md
index.js
package.json
test.js

README.md

new-object Build Status

Objects that you can subscribe to changes. See also: new-list

Install

$ npm install new-object

Usage

prices = newObject({ apple: 3, grape: 4 })
prices('banana', 1)

prices('apple')
// => 3

prices('banana')
// => 1

Subscribing to changes:

prices('cherry', 5)
prices('apple', 2)
prices.rm('banana')

prices.subscribe(function(update){

    update.set
    // => { cherry: 5, apple: 2 }

    update.rm
    // => ['banana']

})

Publishing Custom Updates

people = newObject({ john: { age: 21 city: 'SF' }, smith: { age: 23, city: 'NYC' } })

people.subscribe(function(update){

  if(update.person)
    debug('%s was updated', update.person)

})

people('john').age = 22;
people.publish({ person: 'john' })

See tests for more information.

Something went wrong with that request. Please try again.