Last active
January 3, 2023 09:46
-
-
Save tomByrer/fd763ff2c161b172f719891e2544d428 to your computer and use it in GitHub Desktop.
XState, Action, raise: https://xstate.js.org/viz/?gist=fd763ff2c161b172f719891e2544d428
This file contains 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
// Demostrate `raise` action | |
const stubbornMachine = Machine({ | |
id: 'raisedmo', | |
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