Last active
July 10, 2020 13:48
-
-
Save LinusBorg/892eebe807ded9488bad1caa548181a8 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
This file contains hidden or 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: 'uploader', | |
initial: 'idle', | |
context: { | |
retries: 0 | |
}, | |
on: { | |
RESET: { | |
target: 'idle', | |
actions: ['resetContext'] | |
}, | |
}, | |
states: { | |
idle: { | |
entry: ['resetInputAndData'], | |
on: { | |
PARSE: 'parsing' | |
}, | |
}, | |
parsing: { | |
initial: 'processing', | |
states: { | |
processing: { | |
invoke: { | |
id: 'uploadProcessor', | |
src: 'uploadProcessor', | |
onDone: { | |
target: '#uploader.parsed', | |
actions: ['persistParsedCSVData'], | |
}, | |
onError: { | |
target: 'error', | |
actions: ['setParseErrorMessage'] | |
} | |
} | |
}, | |
error: { | |
}, | |
}, | |
}, | |
parsed: { | |
on: { | |
RESET: 'idle', | |
EXTRACT: 'extraction', | |
} | |
}, | |
extraction: { | |
initial: 'searching', | |
states: { | |
searching: { | |
invoke: { | |
id: 'searchDataetStart', | |
src: 'searchDataetStart', | |
onDone: { | |
target: 'extracting', | |
actions: ['saveDatasetStart'], | |
}, | |
onError: { | |
target: 'searchError', | |
actions: ['setSearchError'] | |
} | |
} | |
}, | |
searchError: { | |
}, | |
extracting: { | |
invoke: { | |
id: 'searchDataetStart', | |
src: 'extractData', | |
onDone: { | |
target: 'extracted', | |
actions: ['saveData'], | |
}, | |
onError: { | |
target: 'extractError', | |
actions: ['setExtractError'] | |
} | |
} | |
}, | |
extractError: {}, | |
extracted: { | |
}, | |
} | |
} | |
} | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment