Skip to content

Instantly share code, notes, and snippets.

@tom-sherman
Created June 4, 2020 08:47
Show Gist options
  • Save tom-sherman/8ede96411bf8d4a41a3cc83b31bb8a11 to your computer and use it in GitHub Desktop.
Save tom-sherman/8ede96411bf8d4a41a3cc83b31bb8a11 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const saleStatusMachine = Machine({
id: 'saleSatus',
initial: 'in_progress',
states: {
in_progress: {
on: {
HOLD: 'held',
COMPLETE: {
target: 'completed',
cond: 'isFullyPaid'
},
PAY: {
target: 'in_progress',
actions: 'makePayment'
},
}
},
held: {
on: {
UNHOLD: 'in_progress'
}
},
completed: {
type: 'final'
},
}
},
{
actions: {
makePayment: (type, amount) => console.log('todo: implementation')
},
guards: {
isFullyPaid: () => true
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment