Skip to content

Instantly share code, notes, and snippets.

@AmagiDDmxh
Created May 19, 2021 16:31
Show Gist options
  • Save AmagiDDmxh/fc9ee7f36eff7bec8cee44a8772c136b to your computer and use it in GitHub Desktop.
Save AmagiDDmxh/fc9ee7f36eff7bec8cee44a8772c136b 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 connectMachine = Machine({
id: 'connect',
initial: 'idle',
context: {
retries: 0
},
states: {
idle: {
on: {
CONNECT: 'connecting'
}
},
connecting: {
on: {
RESOLVE: 'success',
REJECT: 'failure'
}
},
success: {
type: 'final'
},
failure: {
on: {
RETRY: {
target: 'connecting',
actions: assign({
retries: (context, event) => context.retries + 1
})
}
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment