Last active
February 8, 2020 11:26
-
-
Save ika18/9192413c8adb06e20918c5c7449981c0 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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