Created
February 16, 2021 16:15
-
-
Save gretzky/f088af1e62dab12a6ff52fb807442ad2 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
const createDialMachine = Machine({ | |
id: "createDialMachine", | |
initial: "init", | |
context: { | |
createDial: null, | |
error: false, | |
errorMsg: '', | |
retries: 0 | |
}, | |
states: { | |
init: { | |
on: { | |
DEVICE_ID: "deviceId" | |
} | |
}, | |
deviceId: { | |
on: { | |
NEXT: "dialType", | |
EXIT: "init" | |
} | |
}, | |
dialType: { | |
on: { | |
NEXT: "dialName", | |
EXIT: "init" | |
} | |
}, | |
dialName: { | |
on: { | |
NEXT: "creating", | |
BACK: "dialType" | |
} | |
}, | |
creating: { | |
on: { | |
RESOLVE: "complete", | |
REJECT: "failure" | |
} | |
}, | |
complete: { | |
on: { | |
EXIT: "init", | |
ADD_ANOTHER: "deviceId" | |
} | |
}, | |
failure: { | |
on: { | |
RETRY: { | |
target: 'creating', | |
actions: assign({ | |
retries: (ctx, event) => ctx.retries + 1 | |
}) | |
} | |
} | |
} | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment