PDA

View Full Version : Ext.override use or not ?



dedoz
10 Mar 2012, 9:13 PM
Ext.override its deprecated in extjs 4.1 betas
Says now we should use Ext.define with a override config, but using define means we are actually defining another classs

Ext.define('SomeNewClass', {
override: 'SourceClass'
}

and says we should use this as SomeNewClass which at the end is very similar to just extend a class,
overriding a "sourceClass" is to have some part of that class ... overriden, so future use of that sourceClass will use this new overriden code, this works with the deprecated Ext.override, with the new system is just like creating a new class.

i saw "recent" post from a developer team member that used the Ext.override to give a answer to a 4.1 beta question.

http://www.sencha.com/forum/showthread.php?173996

so question is : should i keep using Ext.override and ignore that "deprecated" info without worry bout now is deprecated ?

vadimv
11 Mar 2012, 6:01 AM
Best practices for 4.x is to use Ext.define with override property :



Ext.define (http://docs.sencha.com/ext-js/4-0/#!/api/Ext-method-define)('My.app.PanelPart2',{
override:'My.app.Panel',
constructor:function(config){
this.callSuper(arguments);// calls My.app.Panel's constructor//...}});

And I think it doesn't defines a new class, it's just aggregates the content to the overridden class, and the overridden one is stored in a previous config, thus like a chain, if the user wants later to call the overridden, simple experiment just try to create a instance of 'SomeNewClass'. For better understanding look at Ext.Class code.