Skip to content

Instantly share code, notes, and snippets.

@d34dman
Created June 30, 2020 11:55
Show Gist options
  • Save d34dman/624b5ecf9b50bfa600d7b3d78ba60b62 to your computer and use it in GitHub Desktop.
Save d34dman/624b5ecf9b50bfa600d7b3d78ba60b62 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 teststatus = Machine({
id: 'testSatus',
initial: 'idle',
context: {
retries: 0
},
states: {
idle: {
on: {
SCHEDULE: 'scheduled',
CANCEL: 'failure'
}
},
scheduled: {
on: {
TEST: 'testing',
CANCEL: 'failure'
}
},
testing: {
on: {
TIMEOUT: 'error',
PROCESS: 'processing'
}
},
processing: {
on: {
SUCCESS: 'success',
ERROR : 'error',
EXCEPTION: 'failure'
}
},
success: {
type: 'final'
},
error: {
on : {
CANCEL: 'failure',
RETRY: {
target: 'testing',
actions: assign({
retries: (context, event) => context.retries + 1
})
}
}
},
failure: {
type: 'final'
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment