Page 1 of 1

Periodically calling a service with Ionic 4

Posted: Fri May 01, 2020 3:48 pm
by Joe5648138

I'm trying to automatically execute a service every few seconds, I found some code in the forums but it doesn't appear to work with the Ionic 4 app builder.

var $interval = Apperyio.get("$interval");
$scope.myInterval = $interval(function() {
// put your JS code here
}, 100);

How do I access the $interval function with Ionic 4?

Thank you!


Periodically calling a service with Ionic 4

Posted: Sun May 03, 2020 9:44 pm
by Joe5648138

I found a solution just in case anyone else has this issue. setInterval seems to work just as well since I couldn't figure out how to call the $interval function.

In the before page action:
this.timer = setInterval(() = {
this.updateTimer();
}, 1000);

In the after page action:
clearInterval(this.timer);


Periodically calling a service with Ionic 4

Posted: Mon May 04, 2020 12:35 pm
by Serhii Kulibaba

Glad to hear things are sorted out now! Thank you for the update