Skip to content

Instantly share code, notes, and snippets.

@mellson
Forked from tomByrer/machine.js
Last active January 3, 2023 09:48
Show Gist options
  • Select an option

  • Save mellson/04bff4f2e4c5b4fa7f346dcd7fc21627 to your computer and use it in GitHub Desktop.

Select an option

Save mellson/04bff4f2e4c5b4fa7f346dcd7fc21627 to your computer and use it in GitHub Desktop.
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