Skip to content

Instantly share code, notes, and snippets.

@pangratz
Last active November 9, 2020 18:48
Show Gist options
  • Save pangratz/f1e68d0743abdc3fa728e6d4bf94e009 to your computer and use it in GitHub Desktop.
Save pangratz/f1e68d0743abdc3fa728e6d4bf94e009 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 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