Skip to content

Instantly share code, notes, and snippets.

@joelhooks
Created March 11, 2013 21:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joelhooks/5137906 to your computer and use it in GitHub Desktop.
Save joelhooks/5137906 to your computer and use it in GitHub Desktop.
var machine = {
initial: 'state/STARTING',
states: [
{
name: 'state/STARTING',
transitions: [
{
action: 'action/completed/STARTED',
target: 'state/CONSTRUCTING' //name of the state to move to when event received
},
{
action: 'action/START_FAILED',
target: 'state/FAILING'
}
]
},
{
name: 'state/CONSTRUCTING',
changed: 'event/CONSTRUCT',
exiting: 'event/CONSTRUCTION_EXIT',
entering: 'action/CONSTRUCTION_ENTERING',
transitions: [
{
action: 'action/completed/CONSTRUCTED', //action is the event constant
target: 'NAVIGATING' //name of the state to move to when event received
},
{
action: 'action/CONSTRUCTION_FAILED',
target: 'FAILING'
}
]
},
{
name: 'state/NAVIGATING',
changed: 'event/NAVIGATE'
//no transitions because this is effectively the end of the road
},
{
name: 'state/FAILING',
changed: 'event/FAIL'
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment