Skip to content

Instantly share code, notes, and snippets.

@kimroen
Last active June 12, 2020 12:50
Show Gist options
  • Save kimroen/e5d8c07632009f842f30edd85a5fe5fb to your computer and use it in GitHub Desktop.
Save kimroen/e5d8c07632009f842f30edd85a5fe5fb 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 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