Skip to content

Instantly share code, notes, and snippets.

@zacjones93
Last active May 27, 2022 05:02
Show Gist options
  • Save zacjones93/a616e37cccdcefc4049bc742b51356e5 to your computer and use it in GitHub Desktop.
Save zacjones93/a616e37cccdcefc4049bc742b51356e5 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 telephoneMachine = Machine(
{
id: "telephone",
initial: "idle",
states: {
idle: {
on: {
RECEIVE: "ringing"
}
},
ringing: {
initial: "ringing",
states: {
ringing: "ringing"
},
on: {
TAKE: "onCall",
HANGUP: "idle",
RING: ".ringing"
},
entry: ["logEvent"],
exit: ["logEvent"]
},
onCall: {
on: {
HANGUP: "idle"
}
}
}
},
{
actions: {
logEvent: (context, event) => {
console.log(event.type);
}
}
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment