How Can I run a part of code or script each 2 minutes


#1

Hi
Is there an scheduling or interval settings to run a script or part of code each 1 or 2 minutes?

thanks.


#2

Hi, could you please explain what you’re trying to do that makes this useful?


#3
setInterval( () => { 
            doSomeStuff();
     }, 1000 * 60 * 3);

Theres the way to do it, but as @luukschoen said might be better to see the context for what you need it, to find a better solution than this.


#4

This ugly way is a solution for push notification replacement(In Iran is not working properly) and also updating Geolocation because I couldn’t solution to this problem:


#5

Puting this code in homepage.ts or app.componnent.ts is better placement.?


#6

Well I would make a provider for it and then wrap it inside and then call the provider from the app.componnent.ts when the platform is ready.

But essentialy yes, I would call it from the app.component.ts.


#7

Thank you so much. this is temporary solves my problem.


#8

No problem, good luck!