Created
July 12, 2021 09:12
-
-
Save mfbx9da4/0a97c0512721ec401dd40d6be90fc675 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 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