Skip to content

Commit

Permalink
🐛 [Earwurn] Various fixes (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
beefchimi authored Jan 27, 2023
1 parent 87beb80 commit dffe648
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 18 deletions.
5 changes: 5 additions & 0 deletions .changeset/light-cats-sniff.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'earwurm': patch
---

Solves a `this` binding issue by converting a `Stack` method to an arrow function.
5 changes: 5 additions & 0 deletions .changeset/quiet-years-fly.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'earwurm': patch
---

Removed some `console.log` calls.
5 changes: 5 additions & 0 deletions .changeset/slow-horses-flash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'earwurm': patch
---

Bumps `emitten` to `0.2.0` to solve a `super > accessor` bug.
18 changes: 9 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"release": "npm run build && changeset publish"
},
"dependencies": {
"emitten": "^0.1.0"
"emitten": "^0.2.0"
},
"devDependencies": {
"@changesets/changelog-github": "^0.4.8",
Expand Down
8 changes: 4 additions & 4 deletions src/Stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ export class Stack extends EmittenProtected<StackEventMap> {
return scratchBuffer(this.context);
});

this.#setStateFromQueue();
this.#handleStateFromQueue();

return result;
}
Expand All @@ -177,7 +177,7 @@ export class Stack extends EmittenProtected<StackEventMap> {
fadeMs: secToMs(this.#fadeSec),
});

newSound.on('statechange', this.#setStateFromQueue);
newSound.on('statechange', this.#handleStateFromQueue);
newSound.once('ended', this.#handleSoundEnded);

const newQueue = [...this.#queue, newSound];
Expand Down Expand Up @@ -205,9 +205,9 @@ export class Stack extends EmittenProtected<StackEventMap> {
this.emit('statechange', value);
}

#setStateFromQueue() {
#handleStateFromQueue = () => {
this.#setState(this.playing ? 'playing' : 'idle');
}
};

#handleSoundEnded = (event?: SoundEndedEvent) => {
// TODO: `event` should never be `undefined`.
Expand Down
4 changes: 0 additions & 4 deletions src/helpers/unlock-audio-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ export function unlockAudioContext(
source.disconnect();

INTERACTION_EVENTS.forEach((type) => {
console.log('INTERACTION_EVENTS > remove > type', type);

document.removeEventListener(type, unlock, {capture: true});
});

Expand All @@ -47,8 +45,6 @@ export function unlockAudioContext(
}

INTERACTION_EVENTS.forEach((type) => {
console.log('INTERACTION_EVENTS > add > type', type);

document.addEventListener(type, unlock, {
capture: true,
once: true,
Expand Down

0 comments on commit dffe648

Please sign in to comment.