Skip to content

Instantly share code, notes, and snippets.

@s-m-i-t-a
Created March 23, 2020 21:13
Show Gist options
  • Save s-m-i-t-a/99269db0cb5758a33b26ef86c0c799b5 to your computer and use it in GitHub Desktop.
Save s-m-i-t-a/99269db0cb5758a33b26ef86c0c799b5 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 storeFileMetadata = assign({
file: (context, event) => {
return event.file;
}
});
const uploadImageMachine = Machine(
{
id: 'upload_image',
initial: 'init',
context: {
file: null
},
states: {
init: {
on: {
SELECT: {
target: 'selected',
actions: 'storeFileMetadata'
}
}
},
selected: {
on: {
UPLOAD: 'uploading',
SELECT: {
target: 'selected',
actions: 'storeFileMetadata'
}
}
},
uploading: {
on: {
OK: 'analyzing',
ERROR: 'error'
}
},
analyzing: {
type: 'final'
},
error: {
on: {
SELECT: {
target: 'selected',
actions: 'storeFileMetadata'
}
}
}
}
},
{
actions: { storeFileMetadata }
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment