Created
November 12, 2019 18:41
-
-
Save danielkcz/3606e94a16e34c0929769593216e7914 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
This file contains hidden or 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
// Available variables: | |
// - Machine | |
// - interpret | |
// - assign | |
// - send | |
// - sendParent | |
// - spawn | |
// - raise | |
// - actions | |
// - XState (all XState exports) | |
const myMachine = Machine({ | |
id: 'slide', | |
initial: 'ground', | |
states: { | |
ground: { | |
on: { | |
CLIMB_UP: 'ladder' | |
} | |
}, | |
ladder: { | |
type: 'parallel', | |
onDone: 'topOfSlide', | |
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', | |
} | |
} | |
}, | |
} | |
}, | |
topOfSlide: { | |
on: { | |
CLIMB_DOWN: 'ladder', | |
SLIDE: 'ground' | |
} | |
}, | |
} | |
}) | |
// Make ladder a parallel state | |
// Give it subStates for leftLeg and rightLeg | |
// LIFT_LEFT_LEG and LIFT_RIGHT_LEG should move leftLeg and rightLeg from down to up states | |
// When both leftLeg and rightLeg are `up`, you should transition to topOfSlide |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment