Last active
June 26, 2022 17:43
-
-
Save taktran/cf48ffe899c3e3a0d66754622f583d02 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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