Last active
December 10, 2019 17:11
-
-
Save aurerua/bd00528d78216cb69680a81cc8dcf8ed to your computer and use it in GitHub Desktop.
XState parallel states
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
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