Results 1 to 3 of 3

Thread: Performance consideration: refs vs componentquery

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Sencha User
    Join Date
    Jul 2012
    Posts
    29
    Answers
    2
    Vote Rating
    1
      1  

    Default Unanswered: Performance consideration: refs vs componentquery

    I was just wondering whether its always faster to use refs instead of using componentquery if you are only referencing the item a single time in a controller. I assume that refs use componentquery anyway, but I guess I'm asking whether any cpu cycles are saved by using refs as opposed to just using componentquery

  2. #2
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,422
    Answers
    3901
    Vote Rating
    1271
      0  

    Default

    Yes, refs do use ComponentQuery to lookup and starts at the top and works it's way down and finds all instances matching your selector and then uses the first. This can be bad performance depending how many components you have instantiated.

    Another way is to start at a component and walk up/down to get the reference you are wanting. You can then set that instance as a property to reference whenever.
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it!

    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    Feb 2011
    Location
    Dsseldorf, Germany
    Posts
    594
    Answers
    35
    Vote Rating
    33
      0  

    Default Example plese

    Quote Originally Posted by mitchellsimoens View Post
    Another way is to start at a component and walk up/down to get the reference you are wanting. You can then set that instance as a property to reference whenever.
    So could I ref one item and use this ref as a starting ref inside the ref config?

    This could be helpful to use shorter itemIds as we usually do the following:

    Code:
    refs:{
        currentView: '#myView',
        btnOnView: '#myView #btnOnView'
    }
    So - if I could start the btn ref with at the currentView level, that could help.

Posting Permissions

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