Skip to content

Instantly share code, notes, and snippets.

@rthor
Created April 3, 2023 15:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rthor/cb86357158b7014ff38ad901da0de5de to your computer and use it in GitHub Desktop.
Save rthor/cb86357158b7014ff38ad901da0de5de to your computer and use it in GitHub Desktop.
import { createMachine, actions, assign } from "xstate";
const { raise } = actions;
const stubbornMachine = createMachine({
id: "number",
context: {
numb: 0,
},
on: {
"number.reset": {
actions: assign({
numb: 0,
}),
},
"number.magic": {
actions: [
assign({
numb: (contx) => contx.numb + 70,
}),
raise("internal.process"),
],
},
"internal.process": {
actions: assign({
numb: (contx) => contx.numb / 2,
}),
},
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment