Skip to content

Instantly share code, notes, and snippets.

@vladimir-e
Created February 24, 2020 16:58
Show Gist options
  • Save vladimir-e/fdf62709b0c29479b03e3aafed49cae8 to your computer and use it in GitHub Desktop.
Save vladimir-e/fdf62709b0c29479b03e3aafed49cae8 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// - XState (all XState exports)
const rideMachine = Machine({
id: 'customer ride',
initial: 'new',
context: {
max_time: 5000
},
states: {
new: {
on: {
CREATE: 'visible'
}
},
visible: {
on: {
DRIVER_ACCEPTED: 'booked',
CANCELLED: 'new',
TIMEOUT: 'new'
}
},
'booked': {
on: {
DRIVER_ARRIVES: 'in-progress'
}
},
'in-progress': {
on: {
DESTINATION_REACHED: 'payment_due',
ADD_STOP: 'in-progress'
}
},
payment_due: {
on: {
PAID: 'completed',
}
},
'completed': {
type: 'final'
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment