PDA

View Full Version : Dilemma: Extend Observable or Container(component)? Which is more appropriate?



drian
20 Feb 2011, 1:00 AM
Hi,

I have a dilemma regarding which class I should extend to create a basic module from which all my other classes (basically application pages) will extend.

I've looked at the desktop example and their abstract module extends observable class, and i've also checked the example from "ExtJS in Action" book where it extends the container class.

My concern is regarding the memory leaks that may appear.

If my module extends a container (ext component), i can simply call .destroy() and i clean my component/nested components/data stores/events all at once.

How can I do this if my module class extends observable? My module basically returns a container, if i .destroy that container, am I doing it the right way and i'm safe from memory leaks?

I would really appreciate an answer! Thanks

drian
20 Feb 2011, 7:57 AM
bump :(. anyone?

Condor
21 Feb 2011, 7:11 AM
From your perspective, what exactly is a "module"?

Animal
21 Feb 2011, 7:13 AM
A Container extends Observable anyway, so I don't understand what the dilemma is.

drian
21 Feb 2011, 7:21 AM
Firstly, thanks for answering, thought no one would answer.

A module is basically a "page" in my application. Honestly, a page would return a container with a border layout that has a west and center region. West region is filled with some buttons and the center one with text & some grids. Together with that container there are some events (functions) which are called by the buttons from the west region. These will create windows or other components.

My basic "module" is an abstract class from which all my pages will extend.

I would lean twards my abstract class extending "container" as i can easily .destroy() it and take care of the memory leaks.

What do you suggest Condor?

drian
21 Feb 2011, 7:25 AM
A Container extends Observable anyway, so I don't understand what the dilemma is.

That's true, but on a container i can call .destroy() and i'm assured it won't cause memory leaks, how would i do on a class that extends observable? If my class that extends observable returns a component and i call .destroy on that component...will i be safe ?

Condor
21 Feb 2011, 7:27 AM
Is a 'module' always something visual? In that case I would indeed recommend an Ext.Container as superclass.

If it's more like an MVC Controller then an Observable would be more appropriate.

drian
21 Feb 2011, 7:48 AM
Is a 'module' always something visual? In that case I would indeed recommend an Ext.Container as superclass.

If it's more like an MVC Controller then an Observable would be more appropriate.

Yes, it's something visual together with all the functions that the components in the page are using. So i'll go with extending a container.

Regarding an actual MVC implementation, I'm really looking forward to extjs 4. Is it still viable for 28th this month?