Skip to content

Instantly share code, notes, and snippets.

@taktran
Last active June 26, 2022 17:43
Show Gist options
  • Save taktran/cf48ffe899c3e3a0d66754622f583d02 to your computer and use it in GitHub Desktop.
Save taktran/cf48ffe899c3e3a0d66754622f583d02 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 audioPlayerState = {
id: "audioPlayer",
initial: "idle",
states: {
idle: {
on: {
PLAY_ALL: "playingAll",
TOGGLE_PLAY: "playingAll",
},
},
playingAll: {
initial: "playingTitle",
states: {
playingTitle: {
entry: ["playTitle"],
on: {
FINISHED_PLAYING_TITLE: "playingSummary",
TOGGLE_PLAY: "pausedTitle",
},
},
pausedTitle: {
entry: ["pauseTitle"],
on: {
TOGGLE_PLAY: "playingTitle",
},
},
playingSummary: {
entry: ["playSummary"],
on: {
FINISHED_PLAYING_SUMMARY: "#audioPlayer.idle",
TOGGLE_PLAY: "pausedSummary",
},
},
pausedSummary: {
entry: ["pauseSummary"],
on: {
TOGGLE_PLAY: "playingSummary",
},
},
},
on: {
RESTART: ".playingTitle",
},
},
},
};
const fetchMachine = Machine(audioPlayerState);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment