Last active
December 7, 2020 13:20
-
-
Save dra1n/1f3f0f1007de761c9cf2d2eea3e19341 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz/?gist=1f3f0f1007de761c9cf2d2eea3e19341
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 events = { | |
| RIDE: "RIDE", | |
| RIDE_TAXI: "RIDE_TAXI", | |
| RIDE_BUS: "RIDE_BUS", | |
| WALK: "WALK" | |
| } | |
| const getHomeMachine = Machine({ | |
| type: 'parallel', | |
| states: { | |
| riding_enabled: { | |
| initial: 'no', | |
| states: { | |
| yes: {}, | |
| no: { | |
| on: { | |
| [events.RIDE]: 'yes' | |
| } | |
| } | |
| } | |
| }, | |
| global: { | |
| initial: 'walking', | |
| on: { | |
| [events.RIDE_TAXI]: 'global.riding.taxi', | |
| [events.RIDE_BUS]: 'global.riding.bus' | |
| }, | |
| states: { | |
| idle: { | |
| on: { | |
| [events.RIDE]: 'riding', | |
| [events.WALK]: 'walking' | |
| } | |
| }, | |
| walking: { | |
| on: { | |
| [events.RIDE]: 'riding', | |
| [events.WALK]: 'idle' | |
| } | |
| }, | |
| riding: { | |
| initial: 'bus', | |
| on: { | |
| [events.WALK]: 'walking', | |
| [events.RIDE]: 'idle', | |
| }, | |
| states: { | |
| bus: {}, | |
| taxi: {} | |
| } | |
| } | |
| } | |
| } | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment