Skip to content

Instantly share code, notes, and snippets.

@mrsteveheyes
Created March 23, 2021 21:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrsteveheyes/17b19e4f3883e30937529bb9d0ae3ab4 to your computer and use it in GitHub Desktop.
Save mrsteveheyes/17b19e4f3883e30937529bb9d0ae3ab4 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: 'startDocumentPack',
initial: 'fetching',
context: {
documentPack: {},
signatures: [],
},
states: {
fetching: {
invoke: {
src: 'fetchLatestPack',
onDone: {
target: 'fetched',
actions: 'addDocumentPackToContext',
},
onError: {
target: 'fetched',
actions: 'handleFetchError',
},
},
},
fetched: {
on: {
SIGN_DOCUMENT_PACK: 'signing',
SAVE_DOCUMENT_PACK: 'saving',
},
},
signing: {
invoke: {
src: 'signDocumentPack',
onDone: {
target: 'fetched',
actions: 'addSignatureToContext',
},
onError: {
target: 'fetched',
actions: 'handleAddSignatureError',
},
},
},
saving: {
invoke: {
src: 'saveDocumentPack',
onDone: {
target: 'fetched',
actions: 'handleSaveDocumentPackDone',
},
onError: {
target: 'fetched',
actions: 'handleSaveDocumentPackError',
},
},
},
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment