Package Exports
- st8
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (st8) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
st8

St8 is a tiny state machine for structural describing behaviour of components.
Get started
$ npm install st8
var State = require('st8');
//create a new state instance
var state = new State({
//state 1
1: {
before: function(){
...
},
after: function(){
...
}
},
//state 2
2: {
before: function(){
...
},
after: function(){
...
}
},
//state 3 `before` shortcut - go to 4
3: function(){
return 4
},
//state 4 shortcut (go to 1)
4: 1
//any other state
_: {
before: function(){
//go to 2
return 2
}
}
});
//enter state 3
state.set(3);
//get current state
state.get(); //1
//add event listener
state.on('change', function(to, from){
...
});
State inherits emitter, in that it has methods on
, off
, once
, emit
.
API
State(states [, context])
Create a new state machine based on the states
object. Optionally pass a context
for callbacks.
State.prototype.get()
Get current state.
State.prototype.set(value)
Go to a new state.