Hybrid View

  1. #1
    Sencha User VladimirTechMan's Avatar
    Join Date
    Jun 2012
    Location
    Russia
    Posts
    50
    Vote Rating
    4
    VladimirTechMan is on a distinguished road

      0  

    Default [Sencha Touch 2.1.0 RC1] Why Ext.app.Application.getController() is private?

    [Sencha Touch 2.1.0 RC1] Why Ext.app.Application.getController() is private?


    Method Ext.app.Controller.getController() is deprecated (which was the right design decision, I think) and the documentation clearly suggests using this.getApplication().getController() instead (which is also the right thing, I believe; and it does come in handy sometimes!).

    But Ext.app.Application.getController() is, indeed, marked as private now. Which, to me, contradicts with the suggestion above. Unless Sencha developers have some other plans on that part of Sencha Touch 2 architecture, I would ask to "release" Ext.app.Application.getController() to the public again (by removing the "private" tag from it).

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,548
    Vote Rating
    873
    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


    Cross controller calling isn't 100% recommended. There are better ways to do this like using a utility method for code reuse or setup controller superclass and extend that controller to reuse that code.
    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 VladimirTechMan's Avatar
    Join Date
    Jun 2012
    Location
    Russia
    Posts
    50
    Vote Rating
    4
    VladimirTechMan is on a distinguished road

      0  

    Default


    Oops. I was on a business trip last week and somehow missed your reply to this thread, Mitchell...

    Thanks for your comments. It's understood about Sencha developer's view on implementing controller interactions. The approach with super-classes looks reasonable to me. (Indeed, I think that mixins may be even better for that purpose -- from how I see it, at least.)

    I would suggest that Sencha also reflects the preferred way for controller interactions in the Sencha Touch documentation at some point. The descriptions of Application.getController() and Controller.getController() may be a good place to add such a note. Also, a sentence or two on this topic in the general description of Controller would be nice to have. Thus let's re-qualify my request into one for a doc improvement.

  4. #4
    Sencha User
    Join Date
    Jan 2012
    Location
    London, UK
    Posts
    508
    Vote Rating
    74
    shepsii is a jewel in the rough shepsii is a jewel in the rough shepsii is a jewel in the rough shepsii is a jewel in the rough

      0  

    Default


    I think the right way to do this is events using the application object as the bus, because then only an event name is shared and controllers do not need to know the exact name of methods on other controllers - or even depend on the existence of the other controllers. So this is how I do it. Would be nice for the application object to then be targetable in the control section of the controller config tho.

  5. #5
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,548
    Vote Rating
    873
    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


    Quote Originally Posted by shepsii View Post
    I think the right way to do this is events using the application object as the bus, because then only an event name is shared and controllers do not need to know the exact name of methods on other controllers - or even depend on the existence of the other controllers. So this is how I do it. Would be nice for the application object to then be targetable in the control section of the controller config tho.
    Events are one way and a valid way, you can do it in init

    Code:
    init : function(app) {
        var me = this;
    
        app.on({
            scope : me,
            someevent : me.someFunc
        });
    }
    The issue with events is they can affect performance if you are going to use them a lot. If you have an abstract controller this performance is not an issue as the methods are on the prototype of all subclasses
    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.

  6. #6
    Sencha User
    Join Date
    Jan 2012
    Location
    London, UK
    Posts
    508
    Vote Rating
    74
    shepsii is a jewel in the rough shepsii is a jewel in the rough shepsii is a jewel in the rough shepsii is a jewel in the rough

      0  

    Default


    Good point about performance, Mitchell.

    I add the listeners on the init method already - I'd prefer to do it something like this:
    Code:
    config: {
      control: {
        application: {
          event: 'method'
        }
      }
    }