Skip to content

Instantly share code, notes, and snippets.

@isaacplmann
Last active November 12, 2019 16:21
Show Gist options
  • Save isaacplmann/39ed2fb060e067ec1d9ea412d9928bb8 to your computer and use it in GitHub Desktop.
Save isaacplmann/39ed2fb060e067ec1d9ea412d9928bb8 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: {
},
topOfSlide: {
on: {
CLIMB_DOWN: 'ladder',
SLIDE: 'ground'
}
},
}
}, {
guards: {
}
})
// Add step1 and step2 subStates to ladder
// CLIMB_UP and CLIMB_DOWN should move between those states
// CLIMB_UP from step2 should move to topOfSlide
// CLIMB_DOWN from topOfSlide should move to step2
// Add an isJumping guard that returns true
// Change CLIMB_UP from ground to trigger multiple transitions
// if isJumping then go to step2
// otherwise go to step1
// Refactor so the ground CLIMB_UP transition just goes to ladder
// Add an initial entering state for ladder that has an automatic transition to either step1 or step2 based on the isJumping guard
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment