Skip to content

Instantly share code, notes, and snippets.

@thiagoadsix
Created September 28, 2020 12:11
Show Gist options
  • Save thiagoadsix/c867fbb799791ebf508cc7031ddc4f41 to your computer and use it in GitHub Desktop.
Save thiagoadsix/c867fbb799791ebf508cc7031ddc4f41 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
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