Skip to content

Instantly share code, notes, and snippets.

@aeschylus
Last active August 5, 2021 15:57
Show Gist options
  • Save aeschylus/ef0ad8144a55c4be2563a40c8ce4f28f to your computer and use it in GitHub Desktop.
Save aeschylus/ef0ad8144a55c4be2563a40c8ce4f28f to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
// 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