PDA

View Full Version : How to check if Ext.direct call is in progress



ffanf
13 Mar 2014, 6:22 AM
Hi,

Using Extjs 4.2, what would be the best way to check if there is an ext.direct call currently being made by the browser ?

I'm looking for something completely independent of models, stores and not involving setting a flag when stores start/finish loading.

Is there an pre-built method available I could use from a controller ?

We currently have some low-priority actions taking place at regular interval (notifications, online/offline status, ...), and don't want those to start piling up if there is a longer business-critical query being executed (or if for any reason the server takes longer than usual to respond).

Current (simplified) code:


onLaunch: function() {
var interval = setInterval(function() {
scope.loadNotifications();
scope.loadOnlineStatus();
}, 30000); // refresh every 30 sec
}


Target (simplified) code:


onLaunch: function() {
var interval = setInterval(function() {
if (!scope.extDirectCallInProgress()) {
scope.loadNotifications();
scope.loadOnlineStatus();
}
}, 30000); // refresh every 30 sec
}


Thanks,

mitchellsimoens
18 Mar 2014, 5:22 AM
You may be able to check the transactions MixedCollection on Ext.direct.Manager. If it's empty then no calls are pending, if not then there is a call pending.

ffanf
18 Mar 2014, 7:58 AM
Thanks Mitch that was very useful.

Here is the resulting code.


onLaunch: function() {
var interval = setInterval(function() {
if (Ext.direct.Manager.transactions.getCount() == 0) {
scope.loadNotifications();
scope.loadOnlineStatus();
}
}, 30000); // refresh every 30 sec
}