JavaScript app state manager
JavaScript HTML
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.editorconfig
.gitattributes
.gitignore
LICENSE
README.md
index.html
package.json
skate.js
test.js

README.md

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

Playground

Try skate in your browser