Closed evoyy closed 1 year ago
Thank you for working on this! It had been my intention to build a tear-down method, that does everything the constructor does in reverse. Unfortunately, I never got around to it.
I think a method that does this (do you have any preferences on name, for example cleanup()
, destroy()
, or teardown()
?), should do the following things:
srcNode
from this node? (I'll have to look into this further)onmessage
handler (also needs more investigation)click
event listener for clearing held peaksrequestAnimationFrame
loopI think if we do this, then https://github.com/esonderegger/web-audio-peak-meter/pull/45 won't be necessary. A user could create a new WebAudioPeakMeter
when they want it to be active, and call this method when they don't want it to be active
Whatever you call it is fine with me. My main concern was disconnecting the audio node, because that's the only thing that doesn't get cleaned up implicitly and garbage collected (I remove my meter from the DOM using container.replaceChildren()
which takes care of all that).
https://github.com/esonderegger/web-audio-peak-meter/pull/45 is up to you, but when I pause playback in my app it's nice to not have an unnecessary animation loop running.
Thank you for raising this issue and for suggesting a fix! I incorporated this into https://github.com/esonderegger/web-audio-peak-meter/pull/50 and have published it as version 3.1.0.
Relates to issue https://github.com/esonderegger/web-audio-peak-meter/issues/43