Skip to content

Instantly share code, notes, and snippets.

@tcjr
Created September 30, 2020 14:32
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 tcjr/aa7180840ed5d1781fd5318c3070ce77 to your computer and use it in GitHub Desktop.
Save tcjr/aa7180840ed5d1781fd5318c3070ce77 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 importMachine = Machine({
id: 'questionImport',
context: {},
initial: 'select-file',
states: {
'select-file': {
// Shows the file select / drag & drop screen (FRAME 1, FRAME 15)
on: {
FILE_SELECTED: 'confirm-file'
}
},
'confirm-file': {
// Necessary? Shows the filename with a load button (FRAME 3)
on: {
CONFIRM: 'parsing'
}
},
parsing: {
// Shows "Validating headers..."/"Headers look great!" AND "Validating rows..." etc (FRAME 4, FRAME 5, FRAME 6)
on: {
VALID: 'preview',
INVALID: 'errored'
},
entry: ['startParse']
},
preview: {
// Shows "Headers look great!" AND "Rows look great!" AND summary that should say "You loaded X questions" (FRAME 7)
on: {
UPLOAD: 'uploading',
RESTART: 'select-file'
}
},
uploading: {
on: {
SUCCESS: 'done',
FAIL: 'errored'
},
entry: ['startUpload']
},
errored: {
on: {
RESTART: 'select-file'
}
},
done: {}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment