Skip to content

Instantly share code, notes, and snippets.

@tamebadger
Last active January 29, 2020 09:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tamebadger/abb9e8c51fa4418a85644725a1179a01 to your computer and use it in GitHub Desktop.
Save tamebadger/abb9e8c51fa4418a85644725a1179a01 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const pedestrianStates = {
initial: 'walk',
states: {
walk: {
on: {
PED_COUNTDOWN: 'wait'
}
},
wait: {
on: {
PED_COUNTDOWN: 'stop'
}
},
stop: {},
blinking: {}
}
};
const lightMachine = Machine({
key: 'light',
initial: 'green',
states: {
green: {
on: {
TIMER: 'yellow'
}
},
yellow: {
on: {
TIMER: 'red'
}
},
red: {
on: {
TIMER: {
target: 'green',
cond: {
type: 'searchValid'
}
}
},
...pedestrianStates
}
},
on: {
POWER_OUTAGE: '.red.blinking',
POWER_RESTORED: '.red',
POWER_TEST: {
target: '.red.stop',
cond: {
type: 'test'
}
}
}
},{
guards: {
test: () => true
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment