Skip to content

Instantly share code, notes, and snippets.

@lavaxun
Last active May 19, 2021 10:55
Show Gist options
  • Save lavaxun/afc836ab105662f24d27be1cbe4ceb8e to your computer and use it in GitHub Desktop.
Save lavaxun/afc836ab105662f24d27be1cbe4ceb8e 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 checkoutMachine = Machine({
id: 'order',
initial: 'initial',
states: {
initial: {
on: {
CHECKOUT: 'new'
}
},
new: {
on: {
PAY: 'paid',
CANCEL: 'cancelled'
}
},
paid: {
on: {
PROCESS: 'processing',
CANCEL: 'cancelled',
REFUND: 'refund'
}
},
processing: {
on: {
SHIP: 'shipped',
CANCEL: 'cancelled',
REFUND: 'refund'
}
},
shipped: {
on: {
DELIVER: 'delivered'
}
},
delivered: {
type: 'final',
on: {
REFUND: 'refund'
}
},
cancelled: {
type: 'final'
},
refund: {
type: 'final'
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment