Last active
April 29, 2020 12:26
-
-
Save nandcello/2084672b98e8fa51f6c89c6c16fc615c 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
| // Available variables: | |
| // - Machine | |
| // - interpret | |
| // - assign | |
| // - send | |
| // - sendParent | |
| // - spawn | |
| // - raise | |
| // - actions | |
| // - XState (all XState exports) | |
| const fetchMachine = Machine({ | |
| initial: "idle", | |
| context: { values: {}, error: undefined }, | |
| states: { | |
| idle: { | |
| on: { | |
| SUBMIT_DETAILS: { | |
| target: "submittingDetails", | |
| actions: assign({ | |
| values: (_, e) => { | |
| return { ...e.values }; | |
| }, | |
| }), | |
| }, | |
| }, | |
| }, | |
| submittingDetails: { | |
| invoke: { | |
| src: "addListing", | |
| onDone: { | |
| target: "submissionSuccess", | |
| }, | |
| onError: { | |
| target: "submissionError", | |
| actions: assign({ | |
| error: (_, e) => e.data, | |
| }), | |
| }, | |
| }, | |
| }, | |
| submissionSuccess: { | |
| entry: "handleSuccess", | |
| on: { | |
| "": "idle", | |
| }, | |
| }, | |
| submissionError: { | |
| initial: "displayingNotif", | |
| entry: "handleError", | |
| on: { | |
| SUBMIT_DETAILS: "submittingDetails", | |
| }, | |
| states: { | |
| displayingNotif: { on: { HIDE_NOTIF: "hiddenNotif" } }, | |
| hiddenNotif: {}, | |
| }, | |
| }, | |
| }, | |
| }); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment