Last active
February 8, 2021 04:49
-
-
Save tomByrer/dadd3c237aa1cca572fd5d8dadfad31a 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
// 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