Skip to content

Commit d0eb264

Browse files
authored
fix(WaveSurfer): release plugin references on destroy (#4114)
1 parent 3f201a9 commit d0eb264

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/wavesurfer.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -388,11 +388,11 @@ class WaveSurfer extends Player<WaveSurferEvents> {
388388
this.plugins.push(plugin)
389389

390390
// Unregister plugin on destroy
391-
this.subscriptions.push(
392-
plugin.once('destroy', () => {
393-
this.plugins = this.plugins.filter((p) => p !== plugin)
394-
}),
395-
)
391+
const unsubscribe = plugin.once('destroy', () => {
392+
this.plugins = this.plugins.filter((p) => p !== plugin)
393+
this.subscriptions = this.subscriptions.filter((fn) => fn !== unsubscribe)
394+
})
395+
this.subscriptions.push(unsubscribe)
396396

397397
return plugin
398398
}

0 commit comments

Comments
 (0)