Skip to content

Instantly share code, notes, and snippets.

@kjwierenga
Last active April 24, 2021 19:10
Show Gist options
  • Save kjwierenga/5406eb1a531847db6f924e9f894f44e2 to your computer and use it in GitHub Desktop.
Save kjwierenga/5406eb1a531847db6f924e9f894f44e2 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 fetchMachine = Machine({
id: 'live-audio',
initial: 'stopped',
context: {
retries: 0
},
states: {
stopped:{
on: {
PLAY: 'playing'
}
},
paused: {
on: {
PLAY: 'playing'
}
},
playing: {
entry: ['hideSpinner','showControlBar'],
on: {
ERROR: 'reloading',
ENDED_isLive: 'reloading',
ENDED_notLive: 'stopped',
PAUSE_isLive: 'stopped',
PAUSE_notLive: 'paused',
}
},
reloading: {
entry: ['getSrc','closeErrorDisplay','showSpinner', 'hideControlBar'],
on: {
LOADSTART: { target: 'playing',actions: 'play'}
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment