Results 1 to 3 of 3

Thread: All right if I use instantiation instead of xtype?

  1. #1
    Sencha User Carlos Souza's Avatar
    Join Date
    May 2015
    Location
    Minas Gerais, Brazil.
    Posts
    29
    Answers
    1

    Default Answered: All right if I use instantiation instead of xtype?

    Hello everyone.

    In my views creation I avoid the use of xtypes. I usually create my components through object instantiation, as the example below:

    Code:
    Ext.define('App.view.SomeView', {
        extend: "Ext.window.Window",    
        title: "Sample Window",
        alias:'someAlias',
        initComponent: function(){
            
            var me = this;
            
            this.textfield = Ext.create("Ext.form.TextField",{            
                fieldLabel:'Simple TextField'            
            });
            
            this.form = Ext.create("Ext.form.FormPanel",{
                layout:'form',
                items:[this.textfield]
            });
            
            me.items(this.form);
            me.callParent();        
            
        }
    });

    Is there any problem with doing that? What are the negatives? Do I lose performance?

    Thanks in advance and sorry for my english.

  2. Hi Carlos,


    While I don't have a full understanding of your app you might find this works for "quicker" development for you but other developers might not agree with your approach. What does your code look like if you have say 15 textfield elements (name, address and contact info)? I haven't tested your scenario in a Controller/View Model scenario but you might also run into challenges with trapping events/form handling.


    Regards,
    Bryan

  3. #2
    Sencha - Support Team bjdurham85's Avatar
    Join Date
    Mar 2014
    Posts
    962
    Answers
    55

    Default

    Hi Carlos,


    While I don't have a full understanding of your app you might find this works for "quicker" development for you but other developers might not agree with your approach. What does your code look like if you have say 15 textfield elements (name, address and contact info)? I haven't tested your scenario in a Controller/View Model scenario but you might also run into challenges with trapping events/form handling.


    Regards,
    Bryan

  4. #3
    Sencha User Carlos Souza's Avatar
    Join Date
    May 2015
    Location
    Minas Gerais, Brazil.
    Posts
    29
    Answers
    1

    Default

    Quote Originally Posted by bjdurham85 View Post
    Hi Carlos,


    While I don't have a full understanding of your app you might find this works for "quicker" development for you but other developers might not agree with your approach. What does your code look like if you have say 15 textfield elements (name, address and contact info)? I haven't tested your scenario in a Controller/View Model scenario but you might also run into challenges with trapping events/form handling.


    Regards,
    Bryan
    OK! I think there is no consensus about it ...
    Thank you!

Similar Threads

  1. xclass instantiation
    By demongloom in forum Ext JS 6.x Q&A
    Replies: 1
    Last Post: 13 Jul 2015, 12:07 PM
  2. xclass instantiation
    By demongloom in forum Ext JS 6.x Bugs
    Replies: 0
    Last Post: 1 Jul 2015, 5:00 AM
  3. Using xtype vs. normal instantiation
    By caseyb in forum Ext 3.x: Help & Discussion
    Replies: 17
    Last Post: 21 Oct 2010, 6:56 AM
  4. Does xtype really support lazy instantiation?
    By 7twenty in forum Community Discussion
    Replies: 17
    Last Post: 29 Jul 2008, 9:59 AM
  5. Does xtype really support lazy instantiation?
    By 7twenty in forum Ext 2.x: Help & Discussion
    Replies: 16
    Last Post: 26 Jul 2008, 3:46 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •