import { Machine, actions } from "xstate";
const { raise } = actions;
// 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",
},
},
},
});
The raise()
action creator queues an event to the statechart, in the internal event queue. This means the event is sent immediately on the current “step” of the interpreter.
https://stately.ai/viz/cced7743-87b5-41ad-b09a-c9bdf0ace635
标签:raise,reach,when,middle,action,immediately,event,target From: https://www.cnblogs.com/Answer1215/p/16927908.html