Skip to content

Instantly share code, notes, and snippets.

@jasondavis
Last active November 2, 2021 13:56
Show Gist options
  • Save jasondavis/640e5a9505b9d0b2e210b01dca75f979 to your computer and use it in GitHub Desktop.
Save jasondavis/640e5a9505b9d0b2e210b01dca75f979 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 fetchMachine = Machine({
"initial": "Off",
"states": {
"Off": {
"on": {
"FLICK": "On"
},
"initial": "A",
"states": {
"A": {
"on": {
"FLICK": "A",
"UNBLOCK": "B"
},
"onEntry": {
"type": "startUnblockTimer",
"delay": 2000
},
"onExit": {
"type": "cancelUnblockTimer"
}
},
"B": {}
}
},
"On": {
"on": {
"FLICK": "Off"
},
"initial": "C",
"states": {
"C": {
"on": {
"UNBLOCK": "D"
},
"onEntry": {
"type": "startUnblockTimer",
"delay": 500
},
"onExit": {
"type": "cancelUnblockTimer"
}
},
"D": {
"onEntry": {
"type": "turnOn"
},
"onExit": {
"type": "turnOff"
},
"initial": "E",
"states": {
"E": {
"on": {
"UNBLOCK": "F"
},
"onEntry": {
"type": "startUnblockTimer",
"delay": 500
},
"onExit": {
"type": "cancelUnblockTimer"
},
"initial": "G",
"states": {
"G": {
"on": {
"FLICK": "G"
}
}
}
},
"F": {}
}
}
}
}
}
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment