Created
June 16, 2020 02:23
-
-
Save parker-codes/cb61aac756eeab0e9c4d4e00875b208e 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 increment = context => context.count + 1; | |
| const decrement = context => context.count - 1; | |
| const reset = context => context.count = 0; | |
| const counterMachine = Machine({ | |
| initial: 'active', | |
| context: { | |
| count: 0 | |
| }, | |
| states: { | |
| active: { | |
| on: { | |
| INC: { actions: assign({ count: increment }) }, | |
| DEC: { actions: assign({ count: decrement }) }, | |
| RESET: { actions: assign({ count: reset }) } | |
| } | |
| } | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment