Last active
September 25, 2020 14:44
-
-
Save thiagoadsix/aaeb26ec51ef1e2be1f01dc011652500 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: 'querying', | |
states: { | |
querying: { | |
invoke: { | |
src: () => 'doing query to get squires', | |
onDone: 'selectingSquires', | |
}, | |
}, | |
selectingSquires: { | |
on: { | |
ACTION_ID: 'queryingToValidating', | |
}, | |
}, | |
queryingToValidating: { | |
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: 'selectingSquires', | |
}, | |
selectedSquireNotAvailable: { | |
target: 'not_available', | |
}, | |
}, | |
}, | |
not_available: { | |
invoke: { | |
src: () => 'opa', | |
onDone: { | |
target: 'querying', | |
actions: send('SQUIRE_WILL_BE_RELOADED'), | |
}, | |
} | |
}, | |
}, | |
}, | |
}, | |
}, | |
}, | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment