cocopon / tweakpane

:control_knobs: Compact GUI for fine-tuning parameters and monitoring value changes
https://tweakpane.github.io/docs/
MIT License
3.41k stars 85 forks source link

How to remove event listeners? #579

Closed IvanLi-CN closed 6 months ago

IvanLi-CN commented 8 months ago

Thanks to this project, I can easily add UI functionality.

Currently I use the following code to dynamically create and delete folders:

// add

this.pane.addFolder({
    expanded: this.getRememberedExpanded(),
    // ...
})
  .on("fold", (ev) => {
     this.setRememberedExpanded( ev.expanded );
  })

// remove

this.pane.dispose();

From time to time I would remove the old ones and add new ones to dynamically update the interface. But every time I remove and add, presumably the hander for the fold event is not released, resulting in a memory leak. Is there any way to perform an action like this.pane.off('fold')?

cocopon commented 8 months ago

It makes sense, and currently there is no method like .off(). I'll make sure to add it to my todo list.

cocopon commented 6 months ago

Implemented in #587. Please wait for the next release.

cocopon commented 6 months ago

Released 4.0.3.