Skip to content

Instantly share code, notes, and snippets.

@yeehaa123
Created November 19, 2019 20:48
Show Gist options
  • Save yeehaa123/068c32b7fe6d7b17aa002842ce51715c to your computer and use it in GitHub Desktop.
Save yeehaa123/068c32b7fe6d7b17aa002842ce51715c 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(
{
id: "bot",
initial: "booting",
context: {
controller: "",
health: "UNKNOWN",
cassettes: []
},
states: {
booting: {
invoke: {
src: "getHealth",
onDone: {
target: "booted",
actions: ["initialize", "assignHealth"]
},
onError: {
target: "crashed",
actions: "echo"
}
},
},
booted: {
type: "final",
entry: ["welcome", "listen"]
},
crashed: {
type: "final",
entry: "echo"
}
}
}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment