Last active
April 19, 2021 22:38
-
-
Save mogarick/b94df84c216ec760f3a8a0dfd998c5d2 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
This file contains 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({ | |
// not a parallel machine | |
id: 'light', | |
initial: 'green', | |
states: { | |
green: { | |
on: { TIMER: 'yellow' } | |
}, | |
yellow: { | |
on: { TIMER: 'red' } | |
}, | |
// nested parallel machine | |
red: { | |
type: 'parallel', | |
on:{ | |
TIMER: {target: 'green'}}, | |
states: { | |
walkSign: { | |
initial: 'solid', | |
states: { | |
solid: { | |
on: { TIMER: 'turned_off'}, | |
on: { COUNTDOWN: 'flashing' }, | |
}, | |
flashing: { | |
on: { STOP_COUNTDOWN: 'turned_off' } | |
}, | |
turned_off: { | |
type:'final' | |
} | |
} | |
}, | |
pedestrian: { | |
initial: 'walk', | |
states: { | |
walk: { | |
on: { COUNTDOWN: 'wait' } | |
}, | |
wait: { | |
on: { STOP_COUNTDOWN: 'stop' } | |
}, | |
stop: { | |
type: 'final' | |
} | |
} | |
} | |
} | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment