CallBackery
view release on metacpan or search on metacpan
lib/CallBackery/qooxdoo/callbackery/source/class/callbackery/data/Server.js view on Meta::CPAN
if (origThis.__sessionExpiredHandled) { return; }
origThis.__sessionExpiredHandled = true;
if (window.console) {
window.console.log("Session Expired. Prompting for reload.");
}
callbackery.ui.Busy.getInstance().vanish();
let mb = callbackery.ui.MsgBox.getInstance();
mb.addListenerOnce('choice', () => {
window.location.reload(true);
});
mb.sessionExpired(mb.tr('Session Expired'), mb.xtr(exc.message));
return;
}
}
}
if (exc && !exc.application) {
// communication failure -> retry (idempotent) or dialog
origThis._handleCommsFailure(
function(nextAttempt) { doSend(nextAttempt); },
origMethod,
currentAttempt
);
return;
}
origHandler(ret, exc, id);
};
var params = args.concat([{ qxLocale: localeMgr.getLocale() }]);
// Per-call attempt counter (closure-local, so concurrent callAsync
// invocations never clobber each other's retry state).
var currentAttempt = 1;
var doSend = function(attempt) {
currentAttempt = attempt;
origThis._send(wrapped, methodName, params);
};
doSend(1);
},
/**
* A variant of callAsync which pops up server-generated error messages
* automatically. The handler only ever receives a return value.
*
* @param handler {Function} the callback function.
* @param methodName {String} the name of the method to call.
*/
callAsyncSmart: function(handler, methodName) {
var origHandler = handler;
var superHandler = function(ret, exc, id) {
if (exc) {
callbackery.ui.MsgBox.getInstance().exc(exc);
} else {
origHandler(ret);
}
};
var newArgs = Array.prototype.slice.call(arguments);
newArgs[0] = superHandler;
this.callAsync.apply(this, newArgs);
},
callAsyncSmartBusy: function(handler, methodName) {
var origHandler = handler;
var busy = callbackery.ui.Busy.getInstance();
var superHandler = function(ret, exc, id) {
busy.vanish();
if (exc) {
callbackery.ui.MsgBox.getInstance().exc(exc);
} else {
origHandler(ret);
}
};
var newArgs = Array.prototype.slice.call(arguments);
newArgs[0] = superHandler;
busy.manifest('Running ' + methodName);
this.callAsync.apply(this, newArgs);
}
}
});
( run in 1.878 second using v1.01-cache-2.11-cpan-302cb4679cc )