Skip to content

Instantly share code, notes, and snippets.

@tomByrer
Last active February 8, 2021 04:49
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
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