Stately is a state machine for node.js. It’s currently fairly simple, but eventually should be feature comparable with aasm. Pretty much everything requires/is a state machine, so a reusable state machine module reduces duplication.
Check out example.js for usage, stately.js for implementation.
Given a transition from state “from” to state “to”:
beforeTransition
- callback arguments:
"from"
,"to"
machine.beforeTransition (fn)
- callback arguments:
beforeTransition:from:to
or machine.beforeTransitionmachine.beforeTransition ('from', 'to', fn)
beforeExit:from
machine.beforeExit ('from', fn)
beforeEnter:to
machine.beforeEnter ('to', fn)
afterExit:from
machine.afterExit ('from', fn)
afterEnter:to
machine.afterEnter ('to', fn)
afterTransition:from:to
machine.afterTransition ('from', 'to', fn)
afterTransition
- callback arguments:
"from"
,"to"
machine.afterTransition ('from', 'to', fn)
- callback arguments: