Created
January 3, 2021 01:01
-
-
Save pavankataria/cbc408309957fa1c82a8beaac9b2a3b1 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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