Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between xtype and alias?

What is the difference between xtype and alias used in Sencha? They're both seem to be used as shorthand in different places.

like image 215
ming_codes Avatar asked Apr 13 '12 17:04

ming_codes


2 Answers

When you use "alias" to declare an xtype, you have to preface it with "widget".

Example:

{
   ...
   alias: 'widget.mycomponent'
   ...
}

When you use the xtype property, you can leave the "widget." part off, because that part is assumed:

Example:

{
   ...
   xtype: 'mycomponent'
   ...
}

The reason for the two different properties is because you can declare aliases of things other than "widget", like alias: 'layout.card', which is used in the framework. However, for end-user code that reference view objects, you'll probably be using either

alias: 'widget.mycomponent'

or

xtype: 'mycomponent'
like image 66
Patrick Chu Avatar answered Nov 15 '22 10:11

Patrick Chu


This is really confusing, even Sencha Touch developers team does not have a common opinion.

As far as I know, they design this merely for performance. Alias appears earlier than xtype, they create xtype config because if we don't have to parse the string to get the xtype like before, it's faster.

Anyway, things like xtype, ptype, ltype or most common, alias should be unified and clarified in next releases, said the dev team.

like image 8
Thiem Nguyen Avatar answered Nov 15 '22 11:11

Thiem Nguyen