Created
March 23, 2021 21:43
-
-
Save mrsteveheyes/17b19e4f3883e30937529bb9d0ae3ab4 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: '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