Last active
June 12, 2020 12:50
-
-
Save kimroen/e5d8c07632009f842f30edd85a5fe5fb 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
// Available variables: | |
// - Machine | |
// - interpret | |
// - assign | |
// - send | |
// - sendParent | |
// - spawn | |
// - raise | |
// - actions | |
// - XState (all XState exports) | |
const publishMachine = Machine({ | |
id: 'publisher', | |
initial: 'idle', | |
states: { | |
idle: { | |
on: { | |
start: 'savingFields', | |
} | |
}, | |
savingFields: { | |
on: { | |
saved: 'determiningStart', | |
error: 'error', | |
} | |
}, | |
determiningStart: { | |
on: { | |
uploading: 'uploading', | |
publishing: 'initiatingPublish', | |
poll: 'pollForStateUpdate' | |
} | |
}, | |
uploading: { | |
initial: 'initiating', | |
states: { | |
initiating: { | |
after: { | |
500: 'creatingLoop' | |
} | |
}, | |
creatingLoop: { | |
after: { | |
1000: 'uploadingFile', | |
} | |
}, | |
uploadingFile: { | |
after: { | |
3000: 'uploaded' | |
} | |
}, | |
uploaded: { | |
type: 'final' | |
} | |
}, | |
onDone: 'initiatingPublish', | |
on: { | |
error: 'error' | |
} | |
}, | |
initiatingPublish: { | |
on: { | |
publishInitiated: 'pollForStateUpdate', | |
error: 'error', | |
} | |
}, | |
pollForStateUpdate: { | |
on: { | |
poll: { | |
target: 'pollForStateUpdate', | |
internal: false | |
}, | |
pollDone: 'published', | |
error: 'error' | |
} | |
}, | |
published: { | |
type: 'final' | |
}, | |
error: { | |
on: { | |
retry: 'determiningStart', | |
goBack: 'idle' | |
} | |
} | |
} | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment