Skip to content

Instantly share code, notes, and snippets.

@nordfjord
Last active June 4, 2021 11:02
Show Gist options
  • Save nordfjord/5286adfc15f22c8616c4c3420ee51000 to your computer and use it in GitHub Desktop.
Save nordfjord/5286adfc15f22c8616c4c3420ee51000 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 fetchMachine = Machine({
id: 'fetch',
initial: 'draft',
context: {
amountDue: 30,
amountPaid: 0
},
states: {
draft: {
on: {SUBMIT_FOR_APPROVAL: 'pending_approval'}
},
pending_approval: {
on: {
REDRAFT: 'draft',
APPROVE: 'approved',
REJECT: 'rejected'
}
},
rejected: {on: {REDRAFT: 'draft'}},
approved: {
on: {SUBMIT: 'submitted',
REDRAFT: 'draft'
}
},
submitted: {
on: {
PARTIAL_PAYMENT: 'partially_paid',
FULL_PAYMENT: 'paid',
WRITE_OFF: 'written_off'
}
},
partially_paid: {
on: {FULL_PAYMENT: 'paid', PARTIAL_PAYMENT: 'partially_paid',
WRITE_OFF: 'written_off'
}
},
paid: {type: 'final'},
written_off: {type: 'final'},
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment