Skip to content

Instantly share code, notes, and snippets.

@danielkcz
Created November 12, 2019 18:41
Show Gist options
  • Save danielkcz/3606e94a16e34c0929769593216e7914 to your computer and use it in GitHub Desktop.
Save danielkcz/3606e94a16e34c0929769593216e7914 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
// 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