Created
June 4, 2020 23:41
-
-
Save stephenparish/ff8180297d268e407b7e6d2368a49e1b 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 docuDrawMachine = Machine({ | |
id: 'docudraw', | |
initial: 'idle', | |
states: { | |
idle: { | |
on: { | |
DRAW: 'drawing', | |
UPLOAD: 'uploading' | |
} | |
}, | |
drawing: { | |
on: { | |
SAVE: 'saving' | |
} | |
}, | |
uploading: { | |
on: { | |
// Correct me if I'm wrong here, but it looks like the machine automatically goes from uploading to draw when you hit CROP? | |
CROP: 'committingUploadEdits' | |
} | |
}, | |
committingUploadEdits: { | |
on: { | |
CROP_LOADED: 'drawing' | |
} | |
}, | |
saving: { | |
on: { | |
SUCCESS: 'idle', | |
ERROR: 'error' | |
} | |
}, | |
// Error can be it's own state, or something within idle. Up to you. | |
error: { | |
on: { | |
RETRY: 'saving' | |
} | |
} | |
} | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment