Skip to content

Instantly share code, notes, and snippets.

@darekzak
Last active March 4, 2020 13:49
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 darekzak/c2c7045b351ba9792d0b8023bda506f1 to your computer and use it in GitHub Desktop.
Save darekzak/c2c7045b351ba9792d0b8023bda506f1 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 fetchMachine = Machine({
id: 'fileUpload - stats',
initial: 'idle',
context: {
retries: 0
},
states: {
idle: {
on: {
starUploadProcess: 'parseMedia'
}
},
parseMedia: {
on: {
PARSE_SUCCESS: 'uploadProcess',
PARSE_ERROR: 'sendStats'
}
},
uploadProcess: {
on: {
START_ACTION: {
target: 'sendStats',
actions: ['storeStatsInMemory']
},
SUCCESS_ACTION: {
target: 'sendStats',
actions: ['storeStatsInMemory']
},
ERROR_ACTION: {
target: 'sendStats',
actions: ['storeStatsInMemory']
},
PROGRESS: {
actions: ['storeStatsInMemory']
},
UNLOAD_EVENT: 'storeStatsInLS',
},
},
sendStats: {
on: {
SUCCESS: 'end',
ERROR: 'storeStatsInLS'
}
},
storeStatsInLS: {
type: 'final'
},
end: {
type: 'final'
},
}
},
{
actions: {
storeStatsInMemory: (context, event) => {
alert('storeStatsInMemory action');
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment