Skip to content

Instantly share code, notes, and snippets.

@GuyHarwood
Created December 21, 2019 17:49
Show Gist options
  • Save GuyHarwood/1ee228df0d57d13e8d2ae0370b8cb17f to your computer and use it in GitHub Desktop.
Save GuyHarwood/1ee228df0d57d13e8d2ae0370b8cb17f to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const checkMachine = Machine({
id: 'check',
initial: 'untaken',
context: {
restarts: 0
},
states: {
untaken: {
on: {
ALLOCATE: 'allocated'
}
},
allocated: {
on: {
LOGIN: 'collected'
}
},
collected: {
on: {
RECEIVED: 'submitted'
}
},
submitted: {
on: {
PROCESSING_FAILED: 'rejected',
PROCESSING_SUCCESS: 'complete'
}
},
complete: {
type: 'final' // can we restart after completion?
},
rejected: {
on: {
RESTART: 'untaken' // TODO context.restarts++
}
}
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment