Skip to content

Instantly share code, notes, and snippets.

@mathewtrivett
Last active March 6, 2021 14:57
Show Gist options
  • Save mathewtrivett/31f4bf22020c98c55bb48b765ffca8e0 to your computer and use it in GitHub Desktop.
Save mathewtrivett/31f4bf22020c98c55bb48b765ffca8e0 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 OTPMachine = Machine({
id: 'OTPMachine',
initial: 'idle',
context: {
code: null
},
states: {
idle:{
on: {
GENERATE: 'generating'
}
},
generating: {
initial: 'pending',
onDone: 'idle',
states: {
pending: {
on: {
RESOLVE: {
target: 'success',
actions: assign((context,code) => {
return {
...context,
code
}})
},
REJECT: 'failure'
}
},
success: {
type: 'final'
},
failure: {
on: {
RETRY: 'pending'
}
},
},
},
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment