Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.