1. #1
    Sencha User
    Join Date
    Jul 2012
    Posts
    25
    Answers
    2
    Vote Rating
    1
    jugg1es can only hope to improve

      1  

    Default Unanswered: Performance consideration: refs vs componentquery

    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 - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,631
    Answers
    3452
    Vote Rating
    817
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      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 @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    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
    Düsseldorf, Germany
    Posts
    567
    Answers
    34
    Vote Rating
    31
    Kurt001 has a spectacular aura about Kurt001 has a spectacular aura about

      0  

    Default Example plese

    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.

Thread Participants: 2