Skip to content

Instantly share code, notes, and snippets.

@stephenparish
Created June 4, 2020 23:41
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 stephenparish/ff8180297d268e407b7e6d2368a49e1b to your computer and use it in GitHub Desktop.
Save stephenparish/ff8180297d268e407b7e6d2368a49e1b 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 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