Skip to content

Instantly share code, notes, and snippets.

@aurerua
Last active December 10, 2019 17:11
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 aurerua/bd00528d78216cb69680a81cc8dcf8ed to your computer and use it in GitHub Desktop.
Save aurerua/bd00528d78216cb69680a81cc8dcf8ed to your computer and use it in GitHub Desktop.
XState parallel states
const myMachine = Machine({
id: 'slide',
initial: 'ground',
states: {
ground: {
on: {
CLIMB_UP: 'ladder'
}
},
ladder: {
type: 'parallel',
states: {
leftLeg: {
initial: 'down',
states:{
down: {
on: {
LIFT_LEFT_LEG: 'up',
},
},
up: {
type: 'final'
}
}
},
rightLeg: {
initial: 'down',
states:{
down: {
on: {
LIFT_RIGHT_LEG: 'up',
},
},
up: {
type: 'final'
}
}
}
},
onDone: 'topOfSlide'
},
topOfSlide: {
on: {
CLIMB_DOWN: 'ladder',
SLIDE: 'ground'
}
},
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment