Skip to content

Instantly share code, notes, and snippets.

@amite
Last active March 20, 2020 04:53
Show Gist options
  • Save amite/acd815fbc49f2c5946d2c688425187be to your computer and use it in GitHub Desktop.
Save amite/acd815fbc49f2c5946d2c688425187be to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const lit = {
on: {
BREAK: "broken",
TOGGLE: "unlit"
}
};
const unlit = {
on: {
BREAK: {
target: "broken",
actions: ['logBroken']
},
TOGGLE: "lit"
}
};
const broken = {
type: "final"
};
const states = { unlit,lit, broken };
const initial = "unlit";
const config = {
id: "lightBulb",
initial,
states,
strict: true
};
const lightBulbMachine = Machine(config, {
actions: {
logBroken: () => console.log('I am broken')
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment