Last active
January 31, 2020 11:38
-
-
Save badgeek/0718dbd26fa0671e9bc54fe0d156cde5 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
This file contains hidden or 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 BasicMachine = Machine({ | |
| id: "basicmachine", | |
| initial: "inactive", | |
| context: {}, | |
| states: { | |
| copying : { | |
| id: "copying", | |
| initial: "loading", | |
| states: { | |
| loading: { | |
| invoke: { | |
| id: "getscheduledata", | |
| src: "loadscheduleservice", | |
| onDone: { | |
| target: "creating", | |
| actions: ["assignScheduleData"] | |
| }, | |
| onError: { | |
| target: "#basicmachine.error.loading_fail", | |
| actions: "debug" | |
| } | |
| } | |
| }, | |
| creating: { | |
| invoke: { | |
| id: "createschedule", | |
| src: "createscheduleservice", | |
| onDone: { | |
| target: "#basicmachine.inactive", | |
| actions: "debug" | |
| }, | |
| onError: { | |
| target: "#basicmachine.error.creating_fail", | |
| actions: "debug" | |
| } | |
| } | |
| }}, | |
| }, | |
| error : { | |
| states : { | |
| loading_fail : { | |
| on : { | |
| RETRY : { | |
| target : "#copying.loading" | |
| } | |
| } | |
| }, | |
| creating_fail : { | |
| on : { | |
| RETRY : { | |
| target : "#copying.creating" | |
| } | |
| } | |
| } | |
| } | |
| }, | |
| inactive: { | |
| on: { | |
| DUPLICATE: { | |
| target: "copying" | |
| }, | |
| TOGGLE: { | |
| target: "active", | |
| actions: () => toast.success("go to active") | |
| } | |
| } | |
| }, | |
| active: { | |
| on: { | |
| TOGGLE: { | |
| target: "inactive", | |
| actions: () => toast.success("go to inactive") | |
| } | |
| } | |
| } | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment