Last active
March 6, 2021 14:57
-
-
Save mathewtrivett/31f4bf22020c98c55bb48b765ffca8e0 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 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