@clembo590 wrote:
Hello.
I have written this function:var callTdServer = function(data, onRetryCallBack, maxNumerOfRetry) { if (!maxNumerOfRetry) { maxNumerOfRetry = 1000000; } var deferred = $q.defer(); var counter = 0; var httpPromise = $http(data); var successCallback = function(response) { deferred.resolve(response); }; var errorCallback = function(response) { if (counter < maxNumerOfRetry) { counter++; if (onRetryCallBack) { onRetryCallBack(counter); } $timeout(function() { $http(data).then(successCallback, errorCallback); }, 1000); } else { deferred.reject(response); } }; httpPromise.then(successCallback, errorCallback); return deferred.promise; }
I am calling the function like this:
var showLoading = function (counter) { $ionicLoading.show({ template: counter+ "<br><ion-spinner></ion-spinner>" }); }; var hideLoading = function(){ $ionicLoading.hide(); }; var httpPromise = callTdServer(data, showLoading(counter),10000).then(hideLoading, hideLoading);
What it does it that it tries to call my server, if it does not succeed (because the server is down or the internet of the phone is off or whatever reason) it will call the "showloading" function with a counter to display the user that we are attempting to call the server.
The problem that I have is that in the beginning it works very good. But if you let your phone for a long time (around 1000 seconds), I see the spinner lag and the CPU used by the app increases. If you let the app run for the night it's cannot even move...
is it a bug or did I code something really wrong?
just for info I am testing on android 4.4.4 moto G.thanks in advance.
(please do not tell me something like: you should try to check if the connectivity status of the changes... blablabla, I am asking the question because I do not see anything wrong in the code and Have performance issues because of it).
Posts: 1
Participants: 1