skate
v0.2.0
Published
Manage app state
Downloads
18
Maintainers
Readme
skate
Manage app state
npm install skate --save
Examples
Basic usage
var skate = require('skate')
var state = skate()
state('user', 47) // 47
state('user') // 47
state('dreaming', true) // true
state() // calls state.raw()
state.raw() // {user: 47, dreaming: true}
state('dreaming', false)
state.kill() // {user: 47, dreaming: false}
state.raw() // {}
Multiple instances
var skate = require('skate')
var you = skate()
var me = skate()
you('talking', true)
me('listening', true)
Extension
Use an event emitter to emit events when states change
var state = require('skate')()
var emitter = require('energy')()
state.emit = function(changedStateName) {
emitter.emit(changedStateName)
}
Prevent access to the state hash
var state = require('skate')()
state.raw = function() {}
state('user', 47)
state() // undefined
View the source to see how this works