Results 1 to 6 of 6

Thread: Ext.Direct.removeProvider can't remove a provider

    Success! Looks like we've fixed this one. According to our records the fix was applied for EXTJS-7209 in a recent build.
  1. #1
    Touch Premium Member
    Join Date
    Apr 2011
    Posts
    61

    Default Ext.Direct.removeProvider can't remove a provider

    ExtJS 4.1

    This issue is somewhat abstract, but the following example will serve as an illustration:

    Code:
    // This code is generated by architect when it adds a new direct resource
    Ext.ns("Ext.app.REMOTING_API");
    Ext.app.REMOTING_API = {"descriptor":"Ext.app.REMOTING_API","actions":{"DBICUser":
    {"len":1,"name":"list"}]},"url":"https://devel.mydomain.com/gateway/api/router","type":"remoting"};
    Ext.Direct.addProvider(Ext.app.REMOTING_API);
    
    // Somewhere later, neither of these work
    Ext.Direct.removeProvider(Ext.app.REMOTING_API);
    Ext.Direct.removeProvider(Ext.Direct.providers.first());


    I've noticed some apparent inconsistencies which stop the provider apis from working properly.

    - isProvider is expected to be set, but nothing I've seen so far sets it.
    The only possibility I've seen is that REMOTING_API (or similar) should have it set already.
    That seems like intrusion, though.

    - addProvider adds to the providers mixed collection without a key, and without any derivable id or getKey.

    As a result of these two "issues", removeProvider has two paths to actually find the right provider to remove,
    but neither of them will work:
    - a provider passed in won't be recognised because it isn't isProvider
    - There's no key that can be passed to find the provider in the mixed collection.

    Seems that the solution could be for addProvider to:
    - Set isProvider to true (or have Provider itself do it, even better)
    - check for and id property (which probably won't be there), and otherwise define some sort of key for the provider.

    Thanks

    Gareth

  2. #2
    Sencha Premium User evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    19,250

    Default

    The first remove call will never work, the second should, so that's a bug.

    You could also do:

    Code:
    Ext.require('*');
    
    Ext.onReady(function() {
    
        // This code is generated by architect when it adds a new direct resource
        Ext.ns("Ext.app.REMOTING_API");
        Ext.app.REMOTING_API = {
            id: 'x',
            "descriptor": "Ext.app.REMOTING_API",
            "actions": {
                "DBICUser": [{
                    "len": 1,
                    "name": "list"
                }]
            },
            "url": "https://devel.mydomain.com/gateway/api/router",
            "type": "remoting"
        };
        Ext.Direct.addProvider(Ext.app.REMOTING_API);
        Ext.Direct.removeProvider('x');
    
    });
    Twitter - @evantrimboli
    Former Sencha framework engineer, available for consulting.
    As of 2017-09-22 I am not employed by Sencha, all subsequent posts are my own and do not represent Sencha in any way.

  3. #3
    Touch Premium Member
    Join Date
    Apr 2011
    Posts
    61

    Default

    Evan,

    Why do you say that the first call will never work? It's documented to, isn't it?

    As for adding an id, this code is generated by architect... so I don't really get to.

    I've got a work around, by the way.

    Thanks for your reply

    G

  4. #4
    Sencha Premium User evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    19,250

    Default

    No, it's not. What you're passing is a provider configuration, not a provider instance.

    Code:
    Ext.require('*');
    
    Ext.onReady(function() {
    
        // This code is generated by architect when it adds a new direct resource
        Ext.ns("Ext.app.REMOTING_API");
        Ext.app.REMOTING_API = {
            id: 'x',
            "descriptor": "Ext.app.REMOTING_API",
            "actions": {
                "DBICUser": [{
                    "len": 1,
                    "name": "list"
                }]
            },
            "url": "https://devel.mydomain.com/gateway/api/router",
            "type": "remoting"
        };
        var p = Ext.Direct.addProvider(Ext.app.REMOTING_API);
        Ext.Direct.removeProvider(p);
    });
    Twitter - @evantrimboli
    Former Sencha framework engineer, available for consulting.
    As of 2017-09-22 I am not employed by Sencha, all subsequent posts are my own and do not represent Sencha in any way.

  5. #5
    Touch Premium Member
    Join Date
    Apr 2011
    Posts
    61

    Default

    Sorry, You're spot on right!

    So if the second method worked, I'd be fine.

  6. #6
    Sencha Premium User evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    19,250

    Default

    Yep, you got it. Expect a fix in the next release.
    Twitter - @evantrimboli
    Former Sencha framework engineer, available for consulting.
    As of 2017-09-22 I am not employed by Sencha, all subsequent posts are my own and do not represent Sencha in any way.

Posting Permissions

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