Results 1 to 6 of 6

Thread: Example of Ext.direct.PollingProvider with url being a direct function?

  1. #1
    Sencha Premium Member
    Join Date
    Feb 2009
    Location
    Boca Raton, FL
    Posts
    94

    Default Example of Ext.direct.PollingProvider with url being a direct function?

    So the docs say:
    The url which the PollingProvider should contact with each request. This can also be an imported Ext.Direct method which will accept the baseParams as its only argument.

    Can anyone show me an example of the second sentence being used?

    When I try to use it with a method from the ext direct api, the method gets called forever, the 'data' listener never fires, isConnected() returns false, and disconnect() does diddly.
    Example:
    PHP Code:
                var poller = new Ext.direct.PollingProvider({
                    
    type        'polling',
                    
    url            Ext.app['Web.ExtDemoSuite.NonPersistent'].getTime//no arguments
                    
    listeners    : {
                                    
    data    : {
                                                    
    fn : function(providereventeopts){
                                                        
    alert('Data recieved!');
                                                        var 
    content '<i>' Ext.encode(event.data) + '</i>';
                                                        
    AMain.update({data content});
                                                        
    AMain.body.scroll('b'100000true);
                                                    }
                                            }
                                }
                });

                
    Ext.direct.Manager.addProvider(poller); 
    Apparently i'm doing something wrong?
    When digging through the code of connect():
    PHP Code:
    if (Ext.isFunction(url)) {
                                
    url(me.baseParams); //<---
                            
    } else {
                                
    Ext.Ajax.request({
                                    
    urlurl,
                                    
    callbackme.onData,
                                    
    scopeme,
                                    
    paramsme.baseParams
                                
    });
                            } 
    How does this set the callback or fire the onData event? Why does pollTask show as undefined outside of connect()?

    polling provider is driving me nuts!

  2. #2
    Sencha User
    Join Date
    Apr 2012
    Posts
    5

    Default

    hi, did you find the answer of this?

  3. #3
    Sencha Premium Member
    Join Date
    Feb 2009
    Location
    Boca Raton, FL
    Posts
    94

    Default

    Nope, but then I haven't tried again with the latest version either. I'll have to give it another kick

  4. #4
    Sencha Premium Member
    Join Date
    Jun 2011
    Location
    NL
    Posts
    253
    Answers
    22

    Default

    Ext.Direct PollingProvider can work with an Ext.Direct RemotingProvider function using the 'url' property.

    You have to wrap the Ext.Direct remoting function (along with a callback and scope if needed) in an anonymous function, and pass that to the 'url' property.

    Fiddle:

  5. #5

    Default Adding Custom Headers to Ext.direct.PollingProvider

    Anyone know how to add custom headers to Ext.direct.PollingProvider ?

    Ext.direct.Manager.addProvider(
    {
    type:'polling',
    url: 'localhost/chat',
    id: 'addpoll',
    interval: 5000,
    listeners: {

    data: function(provider, event){
    console.log(provider);
    console.log(event.data);

    //updateMain('<i>' + event.data + '</i>');
    }
    }
    }
    );

    var pollB = Ext.direct.Manager.getProvider('addpoll');I dont want to set Ext.Ajax.defaultHeaders, because I need specific headers for this provider and not all ajax requests.

    Thanks,

  6. #6
    Sencha - Ext JS Dev Team nohuhu's Avatar
    Join Date
    Jun 2011
    Location
    Redwood coast
    Posts
    401
    Answers
    26

    Default

    I'm afraid that there is no easy way to set request headers on per-Provider basis at this time, but it's a good idea worth implementing. The ticket is EXTJS-20013, hopefully it will be merged for 6.1.0.
    Regards,
    Alex.

Posting Permissions

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