Created
December 17, 2019 13:28
-
-
Save zsimo/fa81ee81e82b0620d8a477ab4cbdbe7b 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
// Available variables: | |
// - Machine | |
// - interpret | |
// - assign | |
// - send | |
// - sendParent | |
// - spawn | |
// - raise | |
// - actions | |
// - XState (all XState exports) | |
const lightMachine = Machine({ | |
key: 'light', | |
initial: 'green', | |
states: { | |
green: { | |
on: { | |
TIMER: 'yellow' | |
} | |
}, | |
yellow: { | |
on: { | |
TIMER: 'red' | |
} | |
}, | |
red: { | |
initial: 'walk', | |
// the 'activateCrosswalkLight' activity is started upon entering | |
// the 'light.red' state, and stopped upon exiting it. | |
activities: ['activateCrosswalkLight'], | |
on: { | |
TIMER: 'green' | |
}, | |
states: { | |
walk: { on: { PED_WAIT: 'wait' } }, | |
wait: { | |
// the 'blinkCrosswalkLight' activity is started upon entering | |
// the 'light.red.wait' state, and stopped upon exiting it | |
// or its parent state. | |
activities: ['blinkCrosswalkLight'], | |
on: { PED_STOP: 'stop' } | |
}, | |
stop: {} | |
} | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment