View Full Version : Example of Ext.direct.PollingProvider with url being a direct function?

28 Aug 2012, 6:59 AM
So the docs say:
The url which the PollingProvider should contact with each request. This can also be an imported Ext.Direct (http://docs.sencha.com/ext-js/4-1/#%21/api/Ext.direct.Manager) 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.

var poller = new Ext.direct.PollingProvider({
type : 'polling',
url : Ext.app['Web.ExtDemoSuite.NonPersistent'].getTime, //no arguments
listeners : {
data : {
fn : function(provider, event, eopts){
alert('Data recieved!');
var content = '<i>' + Ext.encode(event.data) + '</i>';
AMain.update({data : content});
AMain.body.scroll('b', 100000, true);


Apparently i'm doing something wrong?
When digging through the code of connect():

if (Ext.isFunction(url)) {
url(me.baseParams); //<---
} else {
url: url,
callback: me.onData,
scope: me,
params: me.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! :D

13 Aug 2013, 4:23 AM
hi, did you find the answer of this?

13 Aug 2013, 6:41 AM
Nope, but then I haven't tried again with the latest version either. I'll have to give it another kick

21 Jul 2014, 2:24 PM
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.


3 Dec 2015, 3:10 PM
Anyone know how to add custom headers to Ext.direct.PollingProvider ?

url: 'localhost/chat',
id: 'addpoll',
interval: 5000,
listeners: {

data: function(provider, event){

//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.


10 Dec 2015, 12:36 PM
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.