Skip to content

Instantly share code, notes, and snippets.

@Zlass
Last active August 27, 2020 19:32
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 Zlass/23ed0eff9f2673ac7cc378264b263d5c to your computer and use it in GitHub Desktop.
Save Zlass/23ed0eff9f2673ac7cc378264b263d5c to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const VolumeStreamsMachine = Machine({
id: 'VolumeStreams',
type: 'parallel',
on: {
volume_changed: {
actions: 'forward_to_parent',
},
volume_muted: {
actions: 'forward_to_parent',
},
volume_unmuted: {
actions: 'forward_to_parent',
},
},
states: {
surroundings: {
invoke: {
id: 'surroundings_volume',
src: 'collapsible_volume',
},
},
streaming: {
initial: 'not_streaming',
states: {
not_streaming: {
on: {
streaming_started: 'volume',
},
},
volume: {
invoke: {
id: 'streaming_volume',
src: 'collapsible_volume',
},
on: {
streaming_ended: 'not_streaming',
},
},
},
},
program: {
initial: 'no_volume',
states: {
no_volume: {
on: {
streaming_ended: {
cond: 'program_has_volume',
target: 'volume',
},
program_switched: {
cond: 'program_has_volume',
target: 'volume',
},
},
},
volume: {
invoke: {
id: 'program_volume',
src: 'collapsible_volume',
},
on: {
streaming_started: 'no_volume',
program_switched: {
cond: 'program_has_no_volume',
target: 'no_volume',
},
},
},
},
},
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment