Skip to content

Instantly share code, notes, and snippets.

@thiagoadsix
Last active September 25, 2020 14:44
Show Gist options
  • Save thiagoadsix/aaeb26ec51ef1e2be1f01dc011652500 to your computer and use it in GitHub Desktop.
Save thiagoadsix/aaeb26ec51ef1e2be1f01dc011652500 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: '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