Skip to content

Instantly share code, notes, and snippets.

@Jpadilla1
Created December 11, 2019 19:03
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 Jpadilla1/656ce479188d4b1ab9330045949b3066 to your computer and use it in GitHub Desktop.
Save Jpadilla1/656ce479188d4b1ab9330045949b3066 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const statusMachine = Machine({
id: 'status-machine',
type: 'parallel',
states: {
polling: {
initial: 'loading',
states: {
loading: {
invoke: {
src: 'sparkRequest',
onDone: 'success',
onError: 'failure',
},
},
success: {
entry: 'transitionToEnabled',
after: {
4000: 'loading',
},
},
failure: {
entry: 'transitionToDisabled',
after: {
4000: 'loading',
},
},
},
},
status: {
initial: 'disabled',
states: {
disabled: {
on: {
enable: 'enabled',
},
},
enabled: {
on: {
disable: 'disabled',
},
},
},
},
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment