Last active
April 29, 2020 02:24
-
-
Save NullVoxPopuli/15a3eb8b7d7c391bcce21d86a041a497 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: 'login', | |
initial: 'waitForData', | |
context: { | |
retries: 0 | |
}, | |
states: { | |
waitForData: { | |
onEntry: 'restartEphemeralConnection', | |
on: { | |
// after typing it all in | |
SUBMIT: 'processLogin', | |
// after selecting a file? | |
UPLOAD: 'uploadFile', | |
// triggered by connection class | |
RECEIVE_OR_SYN: 'qrScanned', | |
} | |
}, | |
qrScanned: { | |
on: { | |
IMPORT: 'importData', | |
CANCEL: 'waitForData', | |
ERROR: 'error', | |
}, | |
}, | |
uploadFile: { | |
invoke: { | |
id: 'handle-file', | |
src: 'handleFile', | |
onDone: 'importData', | |
onError: 'error', | |
} | |
}, | |
importData: { | |
// shows progress | |
on: { | |
DONE: 'success', | |
ERROR: 'error', | |
} | |
}, | |
error: { | |
on: { RETRY: '#login' }, | |
}, | |
processLogin: { | |
invoke: { | |
id: 'handle-login', | |
src: 'handleLogin', | |
onDone: 'success', | |
onError: 'error', | |
} | |
}, | |
success: { | |
onEntry: ['teardownConnection', 'toChats'], | |
type: 'final', | |
}, | |
} | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment