-
8 Mar 2012 11:03 AM #1
First Look At New Class System
First Look At New Class System
Im reading the User Guide trying to understand this :
a.) The example references a constructor method. So one new to ExtJs would logically infer there is some construction responsibilities associated with and provided by the class sytem that I am getting by creating a class this way. The presence of a constructor normally would infer that there is a corresponding destruction semantic.
After all we are talking about a 'Class System' here. Initialization and Destruction have high semantic value in the context of a 'Class System'. So it's logical to assume that there are some hooks in the class system that manage this for the class that I am creating.
Imagine my surprise that the 'user guide' doesn't delve into this topic. So I thought, hmm... since the example code doesn't extend from another class explicitly the important concept of initialization and destruction must be a responsibility of the Ext.Base class. Guess What ! It's not even mentioned there. Hmm....
I have one question , if I"m going to be surprised and confused on such a basic aspect of a 'Class System' as managing the initialization and destruction of an instance how am I going to learn ExtJs ? I can't think of a more central concept to a class system as managing the initialization and destruction of instances.
I'm sorry but the user guide is kind of bizarre . So Ext.Base the api doc's don't deal with this topic and that is the foundation of the ExtJS class system ?
I'm confused already ? Does this system support a destructor or not ? Just a constructor ? Do you have to use 'constructor' ? I'm just guessing that you do. I honestly have no idea, i guess I have to comb through your source code. I thought i was looking at a 'System' ?
This does not look 'System-atic' to me at all.
Sorry for the rant... ( i'm sure there is a lot of cool stuff in ExtJS and engineers sometimes don't possess the best skill for teaching things )
-
8 Mar 2012 11:32 AM #2
You get both constructor and destructor when you make an instance of an Ext class, see this:
Typically, you use both constructor and destroy in your own classes or Ext subclasses, but you don't have to.Code:Ext.define('MyClass', {}); var obj = new MyClass(); Ext.isFunction(obj.destroy) // true Ext.isFunction(obj.constructor) // true
It's best to experiment a little and write your own code, or just take a look at some existing component classes.
-
8 Mar 2012 1:28 PM #3
Right On - Thanks...
Right On - Thanks...
Yea , it looks like you have to write some code with this. I also think the class system should separate members that belong to the class system itself ( like extend ) from members that are part of the class prototype. Why mix those together ?
Surface level concepts should be present in a User Guide.
thanks for the help
m.
-
4 Dec 2012 12:16 AM #4
From what I can see the destroy method on Ext.Base is never called. So what is the purpose of it then..?
Maybe there is something I don't get. Please enlighten me.


Reply With Quote