Skip to content

Instantly share code, notes, and snippets.

@joystick
Last active July 1, 2020 07:45
Show Gist options
  • Save joystick/c869fc41cfd09e5a315984957dc21004 to your computer and use it in GitHub Desktop.
Save joystick/c869fc41cfd09e5a315984957dc21004 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 customerMachine = Machine({
id: 'customer',
initial: 'parsingUrl',
context: {
customerData: {}
},
states: {
parsingUrl: {
on: {
PARSING_SUCCESS: 'loading',
PARSING_ERROR: 'parsingError'
}
},
parsingError: {
type: 'final',
actions: []
},
loading: {
on: {
LOADING_SUCCESS: 'loaded',
LOADING_ERROR: 'failure'
}
},
loaded: {
on: {
EDIT: 'editing',
EXIT: 'redirecting',
UPLOAD_BENEFICIARIES: 'uploadingBeneficiaries',
UPLOAD_TRANSACTIONS: 'uploadingTransactions'
}
},
redirecting: {
type: 'final',
actions: []
},
uploadingBeneficiaries: {
on: {
UPLOADING_BENEFICIARIES_SUCCESS: 'loaded',
UPLOADING_BENEFICIARIES_ERROR: 'failure'
}
},
uploadingTransactions: {
on: {
UPLOADING_TRANSACTIONS_SUCCESS: 'loaded',
UPLOADING_TRANSACTIONS_ERROR: 'failure'
}
},
editing: {
on: {
SAVE: 'saving',
CANCEL: 'loaded'
}
},
saving: {
on: {
SAVING_SUCCESS: 'loaded',
SAVING_ERROR: 'editing'
}
},
failure: {
on: {
RETRY: {
target: 'loading',
actions: assign({
retries: (context, event) => context.retries + 1
})
}
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment