Skip to content

Instantly share code, notes, and snippets.

@tom-sherman
Last active May 4, 2020 13:45
Show Gist options
  • Save tom-sherman/17dacc383a3d8e3473ba6935af431672 to your computer and use it in GitHub Desktop.
Save tom-sherman/17dacc383a3d8e3473ba6935af431672 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 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