Last active
August 5, 2021 15:57
-
-
Save aeschylus/ef0ad8144a55c4be2563a40c8ce4f28f 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 pedestrianStates = { | |
initial: 'walk', | |
states: { | |
walk: { | |
on: { | |
PED_COUNTDOWN: { target: 'wait' } | |
} | |
}, | |
wait: { | |
on: { | |
PED_COUNTDOWN: { target: 'stop' } | |
} | |
}, | |
stop: {}, | |
blinking: {} | |
} | |
}; | |
const fetchMachine = Machine({ | |
key: 'light', | |
initial: 'green', | |
states: { | |
green: { | |
on: { | |
TIMER: { target: 'yellow' } | |
} | |
}, | |
yellow: { | |
on: { | |
TIMER: { target: 'red' } | |
} | |
}, | |
red: { | |
on: { | |
TIMER: { target: 'green' } | |
}, | |
...pedestrianStates | |
} | |
}, | |
on: { | |
POWER_OUTAGE: { target: '.red.blinking' }, | |
POWER_RESTORED: { target: '.red' } | |
} | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment