Skip to content

Instantly share code, notes, and snippets.

@pavankataria
Created January 3, 2021 01:01
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 pavankataria/cbc408309957fa1c82a8beaac9b2a3b1 to your computer and use it in GitHub Desktop.
Save pavankataria/cbc408309957fa1c82a8beaac9b2a3b1 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const lightMachine = Machine({
id: 'light',
initial: 'green',
states: {
green: {
on: { TIMER: 'yellow' }
},
yellow: {
on: { TIMER: 'red' }
},
red: {
type: 'parallel',
states: {
crosswalkNorth: {
initial: 'walk',
states: {
walk: {
on: { PED_WAIT: 'wait' }
},
wait: {
on: { PED_STOP: 'stop' }
},
stop: {
// 'stop' is a final state node for 'crosswalkNorth'
type: 'final'
}
},
onDone: {
actions: 'stopCrosswalkNorth'
}
},
crosswalkEast: {
initial: 'walk',
states: {
walk: {
on: { PED_WAIT: 'wait' }
},
wait: {
on: { PED_STOP: 'stop' }
},
stop: {
type: 'final'
}
},
onDone: {
// 'stop' is a final state node for 'crosswalkEast'
actions: 'stopCrosswalkEast'
}
}
},
onDone: 'green'
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment