View Full Version : Using alias or xtype?

17 Jul 2012, 11:49 AM
I was wondering what the different between defining the alias of your class or the xtype of your class was. For a view, you can put alias: 'widget.home' or xtype: 'home' at the top and later on reference the view using the xtype of 'home'. What's the point of having both?

Ext.define( 'App.view.Home',
extend: 'Ext.Container',
alias: 'widget.home',
xtype: 'home' //accomplishes the same as above
} );

18 Jul 2012, 6:26 AM

Am curious also.

18 Jul 2012, 6:42 AM
xtype is the newer way and of course preferred...I think

19 Jul 2012, 4:21 AM
Using xtype is just simpler and easier for people to get started using it. It actually sets up the alias.

To understand what they are, the alias is a two part value separated by a single period:

[alias type].[type]

alias type is is the type of alias (that's not too descriptive is it? :) ). Values can be like widget (components), store, proxy, reader, etc.

type is the shorthand type of the class. This is the xtype for components or the widget alias type.

So if you have

alias : 'widget.mycomponent'

that is the same as

xtype : 'mycomponent'

IF you have:

alias : 'store.mystore'

You can then create the store like:

store : {
type : 'mystore'

19 Jul 2012, 10:07 AM
Makes sense.
Also, should that last piece of code be:

xtype: 'mystore'

19 Jul 2012, 10:34 AM
No, just type. xtype is only for components