Skip to content

Instantly share code, notes, and snippets.

@aurerua
Last active December 10, 2019 17:15
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/c54808f2c45cb8b60030ff3c8825a1a9 to your computer and use it in GitHub Desktop.
Save aurerua/c54808f2c45cb8b60030ff3c8825a1a9 to your computer and use it in GitHub Desktop.
XState history
const myMachine = Machine({
id: "slide",
initial: "notFlying",
on: {
FLY: "flying"
},
states: {
flying: {
on: {
LAND: "notFlying.hist"
}
},
notFlying: {
initial: "ground",
states: {
ground: {
on: {
CLIMB_UP: "ladder"
}
},
ladder: {
initial: "step1",
states: {
step1: {
on: {
CLIMB_UP: "step2",
CLIMB_DOWN: "#slide.notFlying.ground"
}
},
step2: {
on: {
CLIMB_UP: "#slide.notFlying.topOfSlide",
CLIMB_DOWN: "step1"
}
}
}
},
topOfSlide: {
on: {
CLIMB_DOWN: "ladder.step2",
SLIDE: "ground"
}
},
hist: {
type: "history",
history: "deep"
}
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment