Created
September 28, 2020 12:11
-
-
Save thiagoadsix/c867fbb799791ebf508cc7031ddc4f41 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 bookingMachine = Machine({ | |
id: 'booking', | |
initial: 'choosing', | |
states: { | |
choosing: { | |
type: 'parallel', | |
states: { | |
squire: { | |
initial: 'queryingSquire', | |
states: { | |
queryingSquire: { | |
invoke: { | |
src: () => 'doing query to get squires', | |
onDone: 'selectingSquires', | |
}, | |
}, | |
selectingSquires: { | |
initial: 'waitingAnswer', | |
states: { | |
waitingAnswer: { | |
invoke: { | |
src: () => 'waiting user choose', | |
onDone: { | |
target: 'queryingValidating', | |
actions: send('ACTION_ID'), | |
}, | |
}, | |
}, | |
queryingValidating: { | |
invoke: { | |
src: () => | |
'doing query to get squires again to verify if the choices is available', | |
onDone: 'validating', | |
}, | |
}, | |
validating: { | |
entry: (ctx, e) => { | |
// do the logic on this property | |
return console.log(e) | |
}, | |
on: { | |
selectedSquireAvailable: { | |
target: 'waitingAnswer', | |
}, | |
selectedSquireNotAvailable: { | |
target: 'not_vailable', | |
}, | |
}, | |
}, | |
not_vailable: { | |
invoke: { | |
src: () => 'opa', | |
onDone: { | |
target: 'waitingAnswer', | |
actions: send('SQUIRE_WILL_BE_RELOADED'), | |
}, | |
}, | |
}, | |
}, | |
}, | |
}, | |
}, | |
}, | |
}, | |
}, | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment