Created
June 4, 2021 20:52
-
-
Save jinnkhan88/a07c9de67c85ffac695d7f2c3565866d 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
const multiColor = Machine({ | |
id: "multiColor", | |
initial: "unlit", | |
context:{ | |
color:'#000' | |
}, | |
states: { | |
unlit: { | |
on: { | |
BREAK: "broken", | |
TOOGLE: "lit" | |
} | |
}, | |
lit: { | |
on: { | |
BREAK: "broken", | |
TOOGLE: "unlit", | |
CHANGE_COLOR:{ | |
actions:['changeColor'] | |
} | |
} | |
}, | |
broken: {} | |
} | |
},{ | |
actions:{ | |
changeColor:assign((context,event)=>({ | |
color:event.color | |
})) | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment