Skip to content

Instantly share code, notes, and snippets.

@sergebat
Last active August 29, 2015 14:05
Show Gist options
  • Save sergebat/4ae3e3cffe3d00fc9e65 to your computer and use it in GitHub Desktop.
Save sergebat/4ae3e3cffe3d00fc9e65 to your computer and use it in GitHub Desktop.
MuteTrigger
class MuteTrigger {
private count: number = 0;
private inputSet = {};
mute(reason: string) {
if (this.inputSet[reason]) {
return;
}
this.inputSet[reason] = true;
this.count++;
}
unmute(reason: string) {
if (!this.inputSet[reason]) {
return;
}
this.inputSet[reason] = false;
this.count--;
}
isMuted(): boolean {
return this.count > 0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment