Skip to content

Commit 5fc049e

Browse files
committed
refactor: add players getter to AudioPlayerPool
1 parent 8ca96a7 commit 5fc049e

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/components/AudioPlayer/AudioPlayerPool.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ import { AudioPlayer, type AudioPlayerOptions } from './AudioPlayer';
33
export class AudioPlayerPool {
44
pool = new Map<string, AudioPlayer>();
55

6+
get players() {
7+
return Array.from(this.pool.values());
8+
}
9+
610
getOrAdd = (params: AudioPlayerOptions) => {
711
let player = this.pool.get(params.id);
812
if (player) return player;
@@ -23,13 +27,13 @@ export class AudioPlayerPool {
2327
};
2428

2529
clear = () => {
26-
Array.from(this.pool.values()).forEach((player) => {
30+
this.players.forEach((player) => {
2731
this.remove(player.id);
2832
});
2933
};
3034

3135
registerSubscriptions = () => {
32-
Array.from(this.pool.values()).forEach((p) => {
36+
this.players.forEach((p) => {
3337
p.registerSubscriptions();
3438
});
3539
};

0 commit comments

Comments
 (0)