ExtJs 组件清理

ExtJs component cleanup

我在 ExtJs-in-action 中阅读了以下评论 -

'Do not dismiss the destruction portion of a Component’s lifecycle if you plan on developing your own custom
Components. Many developers have gotten into trouble when they’ve ignored this crucial step and have code that
has left artifacts such as data Stores that continuously poll web servers...'

我从来没有在 3.4.x
上对我的 containers/components 调用显式 destructors/destroy 虽然事情似乎工作正常 - 我很好奇 1. 在哪些情况下实现析构函数变得必不可少
2.what 是在浏览器实例关闭时处理组件销毁的正确约定。

guide 可能是一本好书。

您应该始终考虑在需要释放内存后清理对象,尤其是取消绑定事件侦听器和您使用 setInterval 创建的任何计时器。一旦对象引用被销毁,您将无法访问它,但它可能仍在侦听或触发事件并耗尽资源。

通常在 ExtJs 中,您可以在 destroy 方法中释放资源,但请记住也要调用 callParent() 函数,以便 ExtJs 自行清理。

这是 IBM 在 2012 年发布的另一个 article,似乎更深入地探讨了这个主题。