Last active
September 7, 2020 21:48
-
-
Save jalalazimi/b542c5eac1eb3286254ca40b5552c8d9 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
This file contains hidden or 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 fetchMachine = Machine({ | |
id: "lightBulb", | |
initial: "unlit", | |
states: { | |
lit: { | |
exit:()=>{ | |
console.log("It's so dark and cold") | |
}, | |
on: { | |
BREAK: {target: 'broken',actions: ()=>{ | |
console.log('transition to broken') | |
}}, | |
TOGGLE: "unlit", | |
}, | |
}, | |
unlit: { | |
on: { | |
BREAK: 'broken', | |
TOGGLE: "lit", | |
}, | |
}, | |
broken: { entry: ['logBroken'] }, | |
}, | |
},{ | |
actions: { | |
logBroken: (context,event)=>{console.log(`yo, i'm broken in the ${event.location}` )} | |
} | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment