Created
May 14, 2020 06:20
-
-
Save kappuccino/94577229ffb30ca83a96adc719bbdaef 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
const fetchMachine = Machine({ | |
id: 'lightBulb', | |
initial: 'lit', | |
states: { | |
lit: { | |
exit: () => { | |
console.log('it is cold') | |
}, | |
on: { | |
BREAK: { | |
target: 'broken', | |
actions: () => { | |
console.log('transition to broken') | |
} | |
}, | |
TOGGLE: 'unlit' | |
} | |
}, | |
unlit: { | |
on: { | |
BREAK: 'broken', | |
TOGGLE: 'lit' | |
} | |
}, | |
broken:{ | |
entry: ['logBroken'] | |
} | |
} | |
}, { | |
actions: { | |
logBroken: (ctx, event) => { | |
console.log(`yo i am broke in ${event.location}`) | |
} | |
}}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment