Skip to content

Instantly share code, notes, and snippets.

@pavankataria
Last active December 28, 2021 19:01
Show Gist options
  • Save pavankataria/92c359b4d92e57cf3952b844eba5217a to your computer and use it in GitHub Desktop.
Save pavankataria/92c359b4d92e57cf3952b844eba5217a to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const lightMachine = Machine({
key: 'light',
initial: 'green',
states: {
green: {
on: { NEXT: "yellow" }
},
yellow: { on: { NEXT: "red" }},
red: {
initial: 'green',
states: {
green: {
on: { NEXT: "yellow" }
},
yellow: {
on: { NEXT: "red" }
},
red: {
type: "parallel",
states: {
walkSign: {
initial: "solid",
states: {
solid: {
on: { COUNTDOWN: "flashing" }
},
flashing: {
on: { STOP_COUNTDOWN: "solid"}
}
}
},
pedestrian: {
initial: "walk",
states: {
walk: {
on: {
COUNTDOWN: "wait"
}
},
wait: {
on: {
STOP_COUNTDOWN: "stop"
}
},
stop: {}
}
}
}
}
}
}
}
});
/*const pedestrianStates = {
initial: 'walk',
states: {
walk: {
on: {
PED_COUNTDOWN: 'wait'
}
},
wait: {
on: {
PED_COUNTDOWN: 'stop'
}
},
stop: {},
blinking: {}
}
};
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment