Last active
July 19, 2021 11:44
-
-
Save bautistaaa/1d7adc18a4c7aafab64a9a5c9630d773 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
This file contains 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
const playerMachine = Machine({ | |
id: 'player', | |
initial: 'boot', | |
context: { | |
playbackState: undefined | |
}, | |
states: { | |
boot: { | |
on: { | |
RESOLVE: { target: 'initialized'}, | |
REJECT: { target: 'failed'}, | |
}, | |
}, | |
initialized: { | |
type: 'parallel', | |
states : { | |
playback: { | |
initial: 'idle', | |
states: { | |
idle: { | |
on: { | |
PLAY: 'play' | |
} | |
}, | |
play: { | |
on: { | |
PAUSE: 'pause' | |
} | |
}, | |
pause: { | |
on: { | |
PLAY: 'play' | |
} | |
} | |
} | |
}, | |
shuffle: { | |
initial: 'disabled', | |
states: { | |
disabled: { | |
on: { TOGGLE_SHUFFLE: 'enabled' }, | |
}, | |
enabled: { | |
on: { TOGGLE_SHUFFLE: 'disabled' }, | |
}, | |
}, | |
}, | |
repeat: { | |
initial: 'off', | |
states: { | |
off: { | |
on: { TOGGLE_REPEAT: 'all' }, | |
}, | |
all: { | |
on: { TOGGLE_REPEAT: 'one' }, | |
}, | |
one: { | |
on: { TOGGLE_REPEAT: 'off' }, | |
}, | |
}, | |
}, | |
modifyVolume: { | |
actions: ['modifyVolume'] | |
}, | |
}, | |
}, | |
failed: {} | |
} | |
}, { | |
actions: { | |
modifyVolume: assign({ volume: (_, event) => event.payload.data }), | |
} | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment