Last active
November 9, 2020 18:48
-
-
Save pangratz/f1e68d0743abdc3fa728e6d4bf94e009 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 fetchMachine = Machine({ | |
id: 'fetch', | |
initial: 'not connected', | |
states: { | |
"not connected": { | |
on: { | |
"connect(ip)": { | |
target: "connecting" | |
}, | |
} | |
}, | |
"connecting": { | |
entry: [ | |
"clean current socket", | |
"increase connection counter" | |
], | |
on: { | |
"connection counter OK": { | |
target: "connectToSocketTask running", | |
actions: [ | |
"start timeout task", | |
"start connectToSocketTask" | |
] | |
}, | |
"too many connection attempts": "error" | |
} | |
}, | |
"connectToSocketTask running": { | |
on: { | |
"timeout task finished": { | |
target: "connecting" | |
}, | |
"connectSocketTask finished": { | |
target: "setupSocketConnection" | |
} | |
} | |
}, | |
"setupSocketConnection": {}, | |
"error": {} | |
} | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment