Detach events after the window is closed

I am new to webix, but have almost 15 years of experience in ExtJS.
Currently I’m testing webix, looking for selected solutions and trying to understand how it works.

Problem:
Closing a window (by close method) with a previously connected internal event does not detach this event and leaves the window class instance in memory.

Scenario:

  1. I open the window
  2. attach an app event in the window: this.on(this.app, ...)
  3. I close the window
  4. the event is still running and there is still an instance of the window class

Questions/Expectations:
When closing (via the close method) a window/popup, shouldn’t the instance of the window class be closed? - this will cause automatically detach events via _detachEvents

Close window only destroy root (view:“window”)
No one needs ghost-active instance of the class

Temporary solutions:

  • instead of close(), do this.destructor()
  • after close() call this._detachEvents()

It would be nice to attach events (app,webix) in properties “on”, something like:

return {
  view:"window", 
  ...
  on: {
    // phantom code ... Maybe it's good idea ?
    // like: https://docs.sencha.com/extjs/7.6.0/classic/Ext.Component.html#method-on
    "app:timer": {
        scope: this.app,
        fn: this.winTimer,
    },
    ...
  }, 
  ...
}

… maybe in this situation, destroy view window will cause detach all event from “on” props ?!

All problems are in example:
https://snippet.webix.com/jqmu20q9

I’m not saying that the situation described above is a mistake, but I have doubts about the validity of leaving instances in memory that will no longer be used for anything.
A special case are windows/popups, which (when closed, not hide) should sweep away unnecessary things and clear memory :grinning:

you need to call destructor() on view instance after getRoot().close().
even no need to call getRoot().close() as it will be closed as the result of destructor().
https://snippet.webix.com/b8iqonhk

Like my first option :grinning:

Anyway, thank you for your confirmation.

try not to use private methods like _detachEvents() unless you really sure.
calling destructor() is the right way in your case as it clears inner private fields and prevents memory leakage.