Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ryanve/skate
JavaScript app state manager
https://github.com/ryanve/skate
javascript state-management
Last synced: about 1 month ago
JSON representation
JavaScript app state manager
- Host: GitHub
- URL: https://github.com/ryanve/skate
- Owner: ryanve
- License: mit
- Created: 2015-08-24T04:15:22.000Z (about 9 years ago)
- Default Branch: gh-pages
- Last Pushed: 2017-01-14T07:38:29.000Z (almost 8 years ago)
- Last Synced: 2024-05-02T00:08:46.803Z (7 months ago)
- Topics: javascript, state-management
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/skate
- Size: 6.84 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# skate
#### Manage app state```sh
npm install skate --save
```## Examples
### Basic usage
```js
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
```js
var skate = require('skate')
var you = skate()
var me = skate()
you('talking', true)
me('listening', true)
```## Extension
### Use an [event emitter](https://github.com/ryanve/energy) to emit events when states change
```js
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](skate.js) to see how this works
## Playground
[Try `skate` in your browser](http://ryanve.github.io/skate/)