Last active
June 4, 2021 11:02
-
-
Save nordfjord/5286adfc15f22c8616c4c3420ee51000 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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