1.0.3 • Published 8 years ago

solid-state v1.0.3

Weekly downloads
18
License
MIT
Repository
github
Last release
8 years ago

solid-state npm version Build Status

Triggers listener functions when your state changes

Install

$ npm install --save solid-state

Usage

var SS = require('solid-state')

var optionalInitialState = {}
var AppState = new SS(optionalInitialState)

// Called a function with a clone of the new state whenever state changes
var removeListener = AppState.addListener(function (currentState) {
  someRenderFunction(currentState)
})

// someRenderFunction gets called with {level: 9001}
AppState.set('level', 9001)

// someRenderFunction gets called with {level: 9001, {nested: {property: 'foo'}}
AppState.set('nested.property', 'foo')

AppState.set('will.get.deleted', true)
AppState.del('will');

// {level: 9001, {nested: {property: 'foo'}}
console.log(AppState.get())

// Overwrite the entire state by only providing a value
AppState.set({overwrite: 'state'})

// {overwrite: 'state'}
console.log(AppState.get())

// Stop listening for changes
removeListener()

License

(c) 2015 Chinedu Francis Nwafili. MIT License

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago

0.4.1

8 years ago

0.4.0

8 years ago

0.3.0

9 years ago

0.2.0

9 years ago

0.0.1

9 years ago