Skip to content

Instantly share code, notes, and snippets.

@tomByrer
Last active February 8, 2021 04:49
Show Gist options
  • Save tomByrer/dadd3c237aa1cca572fd5d8dadfad31a to your computer and use it in GitHub Desktop.
Save tomByrer/dadd3c237aa1cca572fd5d8dadfad31a to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
// simple mute volume controll
function mute(){
console.log('🔇 muted')
}
function unmute(){
console.log('👂 unmuted')
}
const volumeMachine = Machine({
id: 'volume',
initial: 'heard',
states: {
heard: { // idle
on: {
MUTE_TOGGLE: 'muted',
},
},
muted: {
entry: ()=> mute(),
on: {
MUTE_TOGGLE: 'heard',
},
exit: ()=> unmute(),
},
}
},
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment