PDA

View Full Version : destroy plugins that generate markup



vladcd
12 Oct 2009, 6:59 AM
Hello everyone,

Since I don't have the right to post replies in this thread: http://www.extjs.com/forum/showthread.php?t=45729&page=2 or in this one http://www.extjs.com/forum/showthread.php?p=322357#post322357 I thought I could raise a question: is there any solution implemented in Ext 3.0 (or will be in Ext 3.1) regarding destroying the plugins of a component(at least the ones generating markup)?

From what I can see, in 3.0 there is nothing implemented regarding this (which is kinda misleading and a source of memory leaks).

I would really appreciate your opinion on this.

Vlad

Animal
12 Oct 2009, 7:04 AM
A plugin must "wrap itself around" the lifecycle of its client Component.

So if it must do something on render it should augment the client's onRender method using a sequence or interceptor.

By the same token, if it must do something on destroy, it should augment the client's onDestroy method.

vladcd
12 Oct 2009, 7:18 AM
Thanks a lot for your answer.

I'll get right on track with the modifications in my project.

Only one more question to wrap this matter up:
- are there any future plans to make the plugin life cycle managed by ext?

Thanks again,
Vlad

Animal
12 Oct 2009, 7:24 AM
You mean automatically call other interface methods of plugins at various points apart from init?

It might be a nice idea, but it'snot up to me.

vladcd
12 Oct 2009, 7:34 AM
Well yeah, that's basically it. As other people have suggested on the threads I linked to initially, something like a base Plugin class(proposed to extend Observable), would be ok.

However, from my point of view, this could cause some real problems to people who made plugins which didn't extend Observable.

So my solution for this would be something like:

Ext.PluginAdapter = function(){
return {
destroy : function(){
....
}

//other methods which might be useful
}
}

In the init method of the plugin class simply call Ext.apply(this, new Ext.PluginAdapter);

And maybe implement the Component method:
beforeDestroy : function(){
if(this.plugins){
for(p in this.plugins){
Ext.destroy(p);
}
}
}

Sorry for the poorly formatted code.
Anyway, I'll try this idea(or something derived from it) and let you know how it worked out.

Thanks again,
Vlad

Animal
12 Oct 2009, 7:37 AM
Use
... tags.