Results 1 to 4 of 4

Thread: Profiles and inheritance. What's the best practice?

  1. #1
    Sencha User interfasys's Avatar
    Join Date
    Mar 2011
    Location
    UK & Switzerland
    Posts
    125
    Vote Rating
    1
      0  

    Default Profiles and inheritance. What's the best practice?

    Let's say I have the following views:
    View1
    Child1
    Child2

    Child views extend View1.
    Now I need to introduce profiles for both View1 and Child1 and things will look like this:
    View1
    Child1
    Child2
    /phone/
    View1
    Child1
    /tablet/
    View1
    Child1

    The problem, of course is that now "phone.Child1" extends Child1 only and doesn't get any of the methods of the super class View1.

    Is the best practice to mix in the "phone.View1" class?
    Code:
    Ext.define('phone.Child1', {
        extend: 'Child1',
        mixins: {
            profileMixin: 'phone.View1'
        },
    Olivier - interfaSys
    Developing custom solutions for BlackBerry 10 using Sencha Touch.

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

    Default

    Are there methods in the phone.View1 that is going to be used in other classes?
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

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

  3. #3
    Sencha User interfasys's Avatar
    Join Date
    Mar 2011
    Location
    UK & Switzerland
    Posts
    125
    Vote Rating
    1
      0  

    Default

    Yes, all the methods of the super class which are specific to that profile.

    Per example, View1 had a onItemSwipe method which Child1 and Child2 were calling.
    Now onItemSwipe has been implemented in the profiles, so in "phone.View1" and "tablet.View1".

    So "phone.Child1" will need the super methods of "phone.View1", but also the ones of non-profile specific "Child1".
    Olivier - interfaSys
    Developing custom solutions for BlackBerry 10 using Sencha Touch.

  4. #4
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,553
    Vote Rating
    1272
      0  

    Default

    You could use mixin or just extend each other... phone.Child1 extends phone.View1, phone.View1 extends Child1
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

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

Posting Permissions

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