Created
September 15, 2021 03:45
-
-
Save nkooman/14c251983a583952471fd277cb62a479 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 States = { | |
IDLE: 'IDLE', | |
CHECKING: 'CHECKING', | |
RESETTING: 'RESETTING', | |
REVEALING: 'REVEALING' | |
}; | |
const Events = { | |
IDLE: { | |
CLICK: 'CLICK' | |
}, | |
CHECKING: { | |
FACEDOWN_FILLED: 'FACEDOWN_FILLED', | |
FACEDOWN_EMPTY: 'FACEDOWN_EMPTY' | |
}, | |
REVEALING: { | |
DONE: 'DONE' | |
}, | |
RESETTING: { | |
FACEUP_FILLED: 'FACEUP_FILLED', | |
FACEUP_EMPTY: 'FACEUP_EMPTY' | |
} | |
}; | |
const stockMachine = Machine({ | |
id: 'stock', | |
initial: States.IDLE, | |
context: { | |
retries: 0 | |
}, | |
states: { | |
[States.IDLE]: { | |
on: { | |
[Events.IDLE.CLICK]: States.CHECKING | |
} | |
}, | |
[States.CHECKING]: { | |
on: { | |
[Events.CHECKING.FACEDOWN_FILLED]: States.REVEALING, | |
[Events.CHECKING.FACEDOWN_EMPTY]: States.RESETTING | |
} | |
}, | |
[States.REVEALING]: { | |
on: { | |
[Events.REVEALING.DONE]: States.IDLE | |
} | |
}, | |
[States.RESETTING]: { | |
on: { | |
[Events.RESETTING.FACEUP_FILLED]: States.REVEALING, | |
[Events.RESETTING.FACEUP_EMPTY]: States.IDLE | |
} | |
} | |
} | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment