Skip to content

Instantly share code, notes, and snippets.

@lucassus
Last active April 13, 2021 11:44
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 lucassus/fee1cf48d23ef3fd5be304bbf26fb06a to your computer and use it in GitHub Desktop.
Save lucassus/fee1cf48d23ef3fd5be304bbf26fb06a to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const vcrMachine = new Machine(
{
id: "videoMachine",
initial: "idle",
context: {
url: null,
video: null,
duration: 0,
elapsed: 0
},
states: {
idle: {
on: {
LOAD: {
target: "loading",
actions: ["load"]
}
}
},
loading: {
on: {
LOADING_SUCCESS: {
target: "loaded",
actions: ["completeLoading"]
},
LOADING_FAILURE: "failure"
}
},
loaded: {
initial: "stopped",
states: {
stopped: {
on: {
PLAY: "playing",
EJECT: "#videoMachine.idle"
}
},
playing: {
entry: "play",
on: {
STOP: {
target: "stopped",
actions: ["stop"]
},
TIMING: {
actions: ["updateElapsed"]
}
}
}
}
},
failure: {
type: "final"
}
}
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment