Created
March 25, 2020 17:04
-
-
Save LevelbossMike/75fa670f88452661b0cb1182c2391d9e 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
| function notifyActionName(context, event) { | |
| window.alert(`Triggered action \`${event.type}\``) | |
| } | |
| const fetchMachine = Machine( { | |
| id: 'quickstart-button-step-6', | |
| initial: 'idle', | |
| states: { | |
| idle: { | |
| on: { | |
| SUBMIT: 'busy', | |
| }, | |
| }, | |
| busy: { | |
| onEntry: ['handleSubmit'], | |
| on: { | |
| SUCCESS: 'success', | |
| ERROR: 'error', | |
| }, | |
| }, | |
| success: { | |
| onEntry: ['handleSuccess'], | |
| }, | |
| error: { | |
| onEntry: ['handleError'], | |
| }, | |
| }, | |
| }, | |
| { | |
| actions: { | |
| handleSubmit: notifyActionName, | |
| handleSuccess: notifyActionName, | |
| handleError: notifyActionName, | |
| }, | |
| } | |
| ); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment