Skip to content

Instantly share code, notes, and snippets.

@Bradleykingz
Created June 30, 2021 09:42
Show Gist options
  • Save Bradleykingz/e9a0dd75e6e94fbe4f9658fd8a27a1ce to your computer and use it in GitHub Desktop.
Save Bradleykingz/e9a0dd75e6e94fbe4f9658fd8a27a1ce to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const fetchMachine = Machine({
id: 'fetch',
initial: 'incomplete',
context: {
retries: 0
},
states: {
incomplete: {
on: {
COMPLETE_ORDER: 'pendingPayment'
}
},
pendingPayment: {
on: {
COMPLETE_PAYMENT: 'pendingConfirmation',
// CANCEL_PAYMENT: 'cancelled',
PAY_ON_DELIVERY: 'pendingConfirmation',
}
},
pendingConfirmation: {
on: {
CONFIRM_ORDER: 'pendingDispatch',
CANCEL_ORDER: 'cancelled'
}
},
pendingDispatch: {
on: {
DISPATCH: 'inTransit'
}
},
inTransit: {
on: {
COMPLETE_DELVIVERY: 'delivered'
}
},
cancelled: {
type: 'final'
},
delivered: {
on: {
LAUNCH_DISPUTE: 'disputed'
}
},
disputed: {
on: {
REFUND_FULLY: 'fullyRefunded',
REFUND_PARTIALLY: 'partiallyRefunded',
REJECT_DISPUTE: 'disputeRejected'
}
},
disputeRejected: {
type: 'final'
},
partiallyRefunded: {
type: 'final'
},
fullyRefunded: {
type: 'final'
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment