-
-
Save mellson/04bff4f2e4c5b4fa7f346dcd7fc21627 to your computer and use it in GitHub Desktop.
XState, Action, raise: https://stately.ai/viz?gist=04bff4f2e4c5b4fa7f346dcd7fc21627
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
| import { createMachine, actions } from "xstate"; | |
| const { raise } = actions; | |
| // Demostrate `raise` action | |
| const raiseActionDemo = createMachine({ | |
| id: 'Raise action demo', | |
| initial: 'entry', | |
| states: { | |
| entry: { | |
| on: { | |
| STEP: { | |
| target: 'middle', | |
| }, | |
| RAISE: { | |
| target: 'middle', | |
| // immediately invoke the NEXT event in 'middle' | |
| actions: raise('NEXT') | |
| }, | |
| }, | |
| }, | |
| middle: { | |
| on: { | |
| NEXT: 'last' | |
| }, | |
| }, | |
| last: { | |
| on: { | |
| RESET: 'entry' | |
| }, | |
| }, | |
| }, | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment