Last active
January 1, 2021 00:24
-
-
Save samihult/f006ebf1cf3cab144190b1a750ed17ac 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', | |
| context: { | |
| value: '', | |
| output: '' | |
| }, | |
| type: 'parallel', | |
| states: { | |
| value: { | |
| initial: 'empty', | |
| states: { | |
| empty: { | |
| on: { | |
| change: { | |
| target: 'not empty', | |
| cond: 'value is not empty' | |
| } | |
| } | |
| }, | |
| 'not empty': { | |
| on: { | |
| change: { | |
| target: 'empty', | |
| cond: 'value is empty' | |
| } | |
| } | |
| } | |
| } | |
| }, | |
| phase: { | |
| initial: 'untouched', | |
| states: { | |
| untouched: { | |
| on: { | |
| change: 'dirty' | |
| } | |
| }, | |
| dirty: { | |
| initial: 'debouncing', | |
| states: { | |
| debouncing: { | |
| after: { | |
| 5000: 'validating' | |
| } | |
| }, | |
| validating: { | |
| on: { | |
| invalid: 'invalid', | |
| valid: 'valid' | |
| } | |
| }, | |
| invalid: {}, | |
| valid: {} | |
| }, | |
| on: { | |
| unfocus: { | |
| target: '.validating', | |
| internal: true | |
| }, | |
| change: { | |
| target: '.debouncing', | |
| internal: false | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| }, { | |
| guards: { | |
| 'value is empty': (context, event) => | |
| context.value === '', | |
| 'value is not empty': (context, event) => | |
| context.value !== '' | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment