Skip to content

Instantly share code, notes, and snippets.

@tomByrer
Last active October 19, 2020 19:27
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 tomByrer/41fb3365af80efff10afb782e9cf9e61 to your computer and use it in GitHub Desktop.
Save tomByrer/41fb3365af80efff10afb782e9cf9e61 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
// orig: https://github.com/eggheadio/eggheadio-course-notes/blob/6a4bcc537c0aa6c301d26e0c929921c18de59ef9/introduction-to-state-machines-using-xstate/notes/15_xstate-simplify-state-explosion-in-xstate-through-hierarchical-states.md
const powerstrip = Machine({
id: 'powerstrip',
initial: 'powerstripOff',
states: {
powerstripOff: {
id: 'basementPowerstriphOff',
on: {
SWITCH_ON: 'poweredOn'
}
},
poweredOn: {
initial: 'notRunning',
states: {
notRunning: {
on: {
SWITCH_OFF: '#basementPowerstriphOff',
FOOTPEDAL_DOWN: 'running'
}
},
running: {
on: {
SWITCH_OFF: '#basementPowerstriphOff',
FOOTPEDAL_RELEASE: 'notRunning'
}
}
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment