Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1
    Sencha Premium Member
    Join Date
    Oct 2011
    Location
    Huntsville
    Posts
    251
    Vote Rating
    -6
    mark0978 is infamous around these parts mark0978 is infamous around these parts

      0  

    Default Proxy.js has Uses where it needs Requires

    Proxy.js has Uses where it needs Requires


    Because of this line in the constructor:
    Code:
            if (this.model !== undefined && !(this.model instanceof Ext.data.Model)) {
                this.setModel(this.model);
            }
    Ext.data.Model should move from the uses to the requires array, like so:


    Code:
    Ext.define('Ext.data.proxy.Proxy', {
        alias: 'proxy.proxy',
        alternateClassName: ['Ext.data.DataProxy', 'Ext.data.Proxy'],
        requires: [
            'Ext.data.reader.Json',
            'Ext.data.writer.Json',
            'Ext.data.Model'
        ],
        uses: [
            'Ext.data.Batch', 
            'Ext.data.Operation', 
            //'Ext.data.Model'
        ],

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


    Can I get a test case where this is a problem?

    Ext.data.Store has Ext.data.Model in the requires so the Ext.data.Model will be required before the proxy is created.
    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 Premium Member
    Join Date
    Oct 2011
    Location
    Huntsville
    Posts
    251
    Vote Rating
    -6
    mark0978 is infamous around these parts mark0978 is infamous around these parts

      0  

    Default


    A Test case is not easily chopped out of my app. Static analysis should show you all you need to know. You can't uses Ext.data.Model in the constructor unless is is defined

    Which part of this don't you understand?

    Code:
    if (this.model !== undefined && !(this.model instanceof Ext.data.Model))
    
    The && means it will be evaluated if you are going to successfully create your Proxy, and you can't use instanceof on an undefined type.

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


    But where will a proxy be used without a Store or a Model? It could actually be removed from the uses and have zero effect except save a little framework size.
    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.

  5. #5
    Sencha Premium Member
    Join Date
    Oct 2011
    Location
    Huntsville
    Posts
    251
    Vote Rating
    -6
    mark0978 is infamous around these parts mark0978 is infamous around these parts

      0  

    Default


    It can't be used without the Model which is why the requires is necessary. You pass the Model NAME (as a string) into the Proxy and you error on the isinstanceof 'Ext.data.Model' because Ext.data.Model does not exist because it wasn't required.

    Part of this probably plays out because of this issue

    http://www.sencha.com/forum/showthre....js-works.-Why

    Which references another bug.

  6. #6
    Touch Premium Member
    Join Date
    Nov 2010
    Location
    Chicago
    Posts
    1,483
    Vote Rating
    218
    LesJ is a splendid one to behold LesJ is a splendid one to behold LesJ is a splendid one to behold LesJ is a splendid one to behold LesJ is a splendid one to behold LesJ is a splendid one to behold LesJ is a splendid one to behold LesJ is a splendid one to behold

      0  

    Default


    Quote Originally Posted by mitchellsimoens View Post
    It could actually be removed from the uses and have zero effect except save a little framework size.
    This would be a mistake as the code base would become harder to understand. Looking at Ext.define, I'd like to know class dependencies even if they are guaranteed to be already loaded.

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


    Code:
    Ext.define('MyModel', {
        extend : 'Ext.data.Model',
    
        fields : [...],
    
        proxy : {
            type : 'ajax',
            ....
        }
    });
    Code:
    Ext.define('MyStore', {
        extend : 'Ext.data.Store',
    
        model : 'SomeModel',
    
        proxy : {
            type : 'ajax',
            ....
        }
    });
    There really is no reason to ever Ext.create('Ext.data.proxy.Ajax', {...})

    And I said we *could* remove it and it would have no affect, not saying we are going to.
    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.

  8. #8
    Sencha Premium Member
    Join Date
    Oct 2011
    Location
    Huntsville
    Posts
    251
    Vote Rating
    -6
    mark0978 is infamous around these parts mark0978 is infamous around these parts

      0  

    Default


    Here is what I'm doing:

    Code:
    Ext.define('IHawk.viewer.data.BatchProxy', {
        extend: 'Ext.data.proxy.Ajax',
        model: 'Batch',
    ...

  9. #9
    Touch Premium Member
    Join Date
    Nov 2010
    Location
    Chicago
    Posts
    1,483
    Vote Rating
    218
    LesJ is a splendid one to behold LesJ is a splendid one to behold LesJ is a splendid one to behold LesJ is a splendid one to behold LesJ is a splendid one to behold LesJ is a splendid one to behold LesJ is a splendid one to behold LesJ is a splendid one to behold

      0  

    Default


    What's the problem to move the dependency from uses to requires? This would make the code more readable even if it doesn't fix anything.

  10. #10
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,626
    Vote Rating
    332
    skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future

      0  

    Default


    In my opinion the requires for a class needs to be correct. Currently it is only used for dynamic loading but who knows what other uses the requires property will have in future, for example in build utilities.

    Given the current code I would say that Ext.data.Model needs to be in the requires for a proxy. The argument that proxies are only ever used with stores/models doesn't work for me.

    One use case (off the top of my head) would be a singleton proxy instance that is shared between many stores. This may be defined before the store/model is loaded and currently I think that would fail.

    I would actually suggest that a better solution to this is to remove the instanceof check and use isModel instead. Something like this maybe:

    Code:
    if (this.model && !this.model.isModel)) {
    There's probably a good reason why the original code explicitly checked for undefined rather than truthyness, but you get the idea.

    This removes the dependency on Ext.data.Model. However, there's still a dependency on Ext.ModelManager that I think should be explicitly included in the requires.

Thread Participants: 3

Tags for this Thread