Last active
December 28, 2021 19:01
-
-
Save pavankataria/92c359b4d92e57cf3952b844eba5217a 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({ | |
key: 'light', | |
initial: 'green', | |
states: { | |
green: { | |
on: { NEXT: "yellow" } | |
}, | |
yellow: { on: { NEXT: "red" }}, | |
red: { | |
initial: 'green', | |
states: { | |
green: { | |
on: { NEXT: "yellow" } | |
}, | |
yellow: { | |
on: { NEXT: "red" } | |
}, | |
red: { | |
type: "parallel", | |
states: { | |
walkSign: { | |
initial: "solid", | |
states: { | |
solid: { | |
on: { COUNTDOWN: "flashing" } | |
}, | |
flashing: { | |
on: { STOP_COUNTDOWN: "solid"} | |
} | |
} | |
}, | |
pedestrian: { | |
initial: "walk", | |
states: { | |
walk: { | |
on: { | |
COUNTDOWN: "wait" | |
} | |
}, | |
wait: { | |
on: { | |
STOP_COUNTDOWN: "stop" | |
} | |
}, | |
stop: {} | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
}); | |
/*const pedestrianStates = { | |
initial: 'walk', | |
states: { | |
walk: { | |
on: { | |
PED_COUNTDOWN: 'wait' | |
} | |
}, | |
wait: { | |
on: { | |
PED_COUNTDOWN: 'stop' | |
} | |
}, | |
stop: {}, | |
blinking: {} | |
} | |
}; | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment