Skip to content

Instantly share code, notes, and snippets.

@thiagoadsix
Last active September 24, 2020 20:36
Show Gist options
  • Save thiagoadsix/643812a5ee4fae71844129a1e86deb55 to your computer and use it in GitHub Desktop.
Save thiagoadsix/643812a5ee4fae71844129a1e86deb55 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: {
on: {
'': {
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