Skip to content

Instantly share code, notes, and snippets.

@mfbx9da4
Created July 12, 2021 09:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mfbx9da4/0a97c0512721ec401dd40d6be90fc675 to your computer and use it in GitHub Desktop.
Save mfbx9da4/0a97c0512721ec401dd40d6be90fc675 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 error = 'error'
const fetchMachine = Machine({
id: 'wormhole',
initial: 'idle',
context: {
retries: 0
},
states: {
idle: {
on: {
dial_alice: 'wait_for_pake_a',
dial_bob: 'wait_for_pake_b',
error: 'error'
}
},
wait_for_pake_a: {
on: {
pake_a: 'success',
error: 'error'
}
},
wait_for_pake_b: {
on: {
pake_b: 'success',
error: 'error'
}
},
success: {
type: 'final'
},
error: {
on: {
retry: {
target: 'idle',
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