Gelmiş geçmiş en büyük porno sitemiz olan 2pe de her zaman en kaliteli pornoları sunmayı hedefledik. Diğer video sitemiz olan vuam da ise hd porno ağırlıklı çalışmalara başladık.

  1. #1
    Sencha User
    Join Date
    Oct 2007
    Posts
    17
    Vote Rating
    0
    dhurlburtusa is on a distinguished road

      0  

    Default What's the difference between 'requires' and 'uses' when defining a class?

    What's the difference between 'requires' and 'uses' when defining a class?


    What's the difference between 'requires' and 'uses' when defining a class? I can't find good documentation on this.

    What's the advantage of using one over the other?

    From a quick glance at the code, it appears the classes declared in the 'uses' array will still be loaded. So why not just put them in the 'requires' array?

  2. #2
    Sencha User ykey's Avatar
    Join Date
    Mar 2010
    Location
    USA
    Posts
    245
    Vote Rating
    27
    ykey has a spectacular aura about ykey has a spectacular aura about

      0  

    Default


    From http://dev.sencha.com/deploy/ext-4.0...iew/index.html

    Uses are optional class dependencies that are used by, but not required by, a class. These can be loaded asynchronously and do not have to be available for the class to be instantiated.

    Not sure that helps any.

  3. #3
    Sencha User
    Join Date
    Oct 2007
    Posts
    17
    Vote Rating
    0
    dhurlburtusa is on a distinguished road

      0  

    Default


    I must of missed that section in the overview. Thanks.

    It helps a little. However, it seems that if a class uses another class, then won't it be required to function correctly?

    Maybe it is used when a class may need another class but only if configured in a certain way. For example, class A depends on Class B only if a certain config option is set. Would we have to use Ext.require('ClassB'); if we set this config option or will Class B have already been loaded if it were declared in the 'uses' array?

  4. #4
    Sencha - Sencha Touch Dev Team Jacky Nguyen's Avatar
    Join Date
    Jul 2009
    Location
    Palo Alto, California
    Posts
    469
    Vote Rating
    14
    Jacky Nguyen has a spectacular aura about Jacky Nguyen has a spectacular aura about

      2  

    Default


    It's easy to explain with an example:

    Code:
    Ext.define('A', {
        requires: ['B'],
        uses: ['C']
    }, function() { // This callback function is invoked right when class A is created
        // Both A and B are ready here, but C is not
    });
    Break-down of what would happen behind the scene:

    - B is dynamically loaded if it doesn't yet exist
    - A is created, the callback is executed
    - C is loaded

    The same applies with:

    Code:
    Ext.require('A', function() {
        // Both A and B are ready here, but C is not 
    });
    However:

    Code:
    Ext.require('A');
    
    Ext.onReady(function(){
        // A, B and C are all available
    });
    Another purpose of 'uses' is to 'temporarily' solve deadlock situation. A bad class design would normally lead to a deadlock, for example:

    - A extends B
    - B mixins C
    - C requires A

    Sometimes refactoring the code base is not applicable due to certain objective / subjective reasons, and deadlock could be solved by deferring the loading priority of a certain class. The above example could be changed to:

    - A extends B
    - B mixins C
    - C uses A

    This occasionally happened when migrating dinosaur code to the new class system.
    Sencha Touch Lead Architect

  5. #5
    Sencha User steffenk's Avatar
    Join Date
    Jul 2007
    Location
    Haan, Germany
    Posts
    2,656
    Vote Rating
    6
    steffenk has a spectacular aura about steffenk has a spectacular aura about steffenk has a spectacular aura about

      0  

    Default


    so the conclusion sounds like: don't use "uses" regulary, it's just needed for some tenuous situations. Right?
    vg Steffen
    --------------------------------------
    Release Manager of TYPO3 4.5

  6. #6
    Sencha User ykey's Avatar
    Join Date
    Mar 2010
    Location
    USA
    Posts
    245
    Vote Rating
    27
    ykey has a spectacular aura about ykey has a spectacular aura about

      0  

    Thumbs up


    Please add this explanation to the docs.

  7. #7
    Sencha User
    Join Date
    Feb 2008
    Location
    Italy
    Posts
    20
    Vote Rating
    0
    BrightSoul is on a distinguished road

      0  

    Default


    Is this available in Sencha Touch as well? I can't find Ext.define and Ext.require in Sencha Touch Api Documentation...

    If not, is it ok to use Ext Core alongside Sencha Touch?

Similar Threads

  1. Two ways of creating custom class in ExtJS: what's the difference?
    By charris in forum Ext 3.x: Help & Discussion
    Replies: 2
    Last Post: 7 Nov 2010, 11:48 PM
  2. Replies: 0
    Last Post: 18 Dec 2009, 8:42 AM
  3. difference between xtype and custom class... why??
    By tarini in forum Ext 2.x: Help & Discussion
    Replies: 7
    Last Post: 21 Jan 2009, 5:13 AM
  4. Tip: About includes / requires
    By achebv in forum Community Discussion
    Replies: 10
    Last Post: 6 Oct 2008, 10:45 AM

Thread Participants: 4