Created
May 6, 2021 03:55
-
-
Save adamfortuna/f2ca8313a5b4f6c4d43ecd5c8204c9e0 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
This file contains 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
const uploaderMachine = Machine({ | |
id: 'uploader', | |
initial: 'idle', | |
context: { | |
input: undefined, | |
payload: undefined, | |
activeImport: undefined, | |
message: undefined | |
}, | |
states: { | |
idle: { | |
on: { | |
PARSE: 'parsing' | |
} | |
}, | |
parsing: { | |
entry: ['parsePayload'], | |
on: { | |
REJECTED: { | |
target: 'rejected', | |
actions: ['setMessage'] | |
}, | |
PROCESSED: { | |
target: 'uploading', | |
actions: ['setPayload'] | |
} | |
} | |
}, | |
rejected: { | |
entry: ['resetForm'], | |
on: { | |
PARSE: 'parsing' | |
} | |
}, | |
uploading: { | |
entry: ['uploadPayload'], | |
on: { | |
UPLOADED: 'waiting', | |
REJECTED: 'rejected' | |
} | |
}, | |
waiting: { | |
entry: ['loadImport'], | |
on: { | |
ERROR: 'error', | |
PROCESS: 'processing' | |
} | |
}, | |
processing: { | |
on: { | |
COMPLETE: 'completed', | |
ERROR: 'error' | |
} | |
}, | |
completed: { | |
type: 'final' | |
}, | |
error: { | |
type: 'final' | |
} | |
}, | |
}, { | |
actions: { | |
setPayload: assign((ctx, event) => ({ | |
results: event.results | |
})), | |
setMessage: assign((ctx, event) => ({ | |
message: event.message | |
})) | |
} | |
} | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment