Skip to content

Instantly share code, notes, and snippets.

@ika18
Last active February 8, 2020 11:26
Show Gist options
  • Save ika18/9192413c8adb06e20918c5c7449981c0 to your computer and use it in GitHub Desktop.
Save ika18/9192413c8adb06e20918c5c7449981c0 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 lit = {
exit: () => {
console.log('it is so dark and cold')
},
on: {
BREAK:'broken',
TOGGLE: "unlit"
}
};
const unlit = {
on: {
BREAK: 'broken',
TOGGLE: "lit"
}
};
const broken = {
entry: ['logBroken']
};
const states = { lit, unlit, broken };
const initial = "unlit";
const config = {
id: "lightBulb",
initial,
states
};
const lightBulbMachine = Machine(config, {
actions: {
logBroken: (context, event) => {
console.log(`yo I am broke in the ${event.location}`)
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment