Last active
January 1, 2021 00:25
-
-
Save samihult/91f3f2ef407216c48431247781e8268e 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 machine = Machine({ | |
| id: 'field', | |
| type: 'parallel', | |
| states: { | |
| value: { | |
| initial: 'empty', | |
| states: { | |
| empty: { | |
| on: { | |
| change: 'not empty' | |
| } | |
| }, | |
| 'not empty': { | |
| on: { | |
| change: 'empty' | |
| } | |
| } | |
| } | |
| }, | |
| phase: { | |
| initial: 'untouched', | |
| states: { | |
| untouched: { | |
| on: { | |
| change: 'dirty' | |
| } | |
| }, | |
| dirty: { | |
| initial: 'debouncing', | |
| states: { | |
| debouncing: { | |
| on: { | |
| timeout: 'validating' | |
| } | |
| }, | |
| validating: { | |
| on: { | |
| invalid: 'invalid', | |
| valid: 'valid' | |
| } | |
| }, | |
| invalid: {}, | |
| valid: {} | |
| }, | |
| // Attaching the transitions to the superstate | |
| // essentially is equal to having those transitions | |
| // from all the substates. "Internal" means that we | |
| // do not exit en re-enter the superstate, which is | |
| // important because of any events attached to it. | |
| on: { | |
| unfocus: { | |
| target: '.validating', | |
| internal: true | |
| }, | |
| change: { | |
| target: '.debouncing', | |
| internal: true | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment