Here is what I would do if internet connections become a problem.
The pertinent section is:
var connections,waiting;
connections = 0;
waiting = false;
function startConnection () {
connections++;
if (!waiting) {
waiting = true;
timedLoop(500,waitingForConnection);
}
}
function endConnection () {
connections--;
if (connections === 0) {
waiting = false;
stopTimedLoop();
hideWaitMessage();
}
}
function waitingForConnection () {
showWaitMessage();
}
Call startConnection();
before every database action. Then in the callback call endConnection();
. The only additional thing is to add showWaitMessage
and hideWaitMessage
to pop up an appropriate label or screen.