Skip to content

Instantly share code, notes, and snippets.

@LinusBorg
Last active July 10, 2020 13:48
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 LinusBorg/892eebe807ded9488bad1caa548181a8 to your computer and use it in GitHub Desktop.
Save LinusBorg/892eebe807ded9488bad1caa548181a8 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: '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