jbr / stately.js

state machine dsl for node

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Stately.js

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.

Callback chain

Given a transition from state “from” to state “to”:

  1. beforeTransition
    • callback arguments: "from", "to"
    • machine.beforeTransition (fn)
  2. beforeTransition:from:to or machine.beforeTransition
    • machine.beforeTransition ('from', 'to', fn)
  3. beforeExit:from
    • machine.beforeExit ('from', fn)
  4. beforeEnter:to
    • machine.beforeEnter ('to', fn)
  5. afterExit:from
    • machine.afterExit ('from', fn)
  6. afterEnter:to
    • machine.afterEnter ('to', fn)
  7. afterTransition:from:to
    • machine.afterTransition ('from', 'to', fn)
  8. afterTransition
    • callback arguments: "from", "to"
    • machine.afterTransition ('from', 'to', fn)

About

state machine dsl for node


Languages

Language:JavaScript 100.0%