I need to automatically update a variable maxReq
, which keeps track of the number of requests sent. At the beginning of the application, every 60 seconds, the variable should be reset to 100
.
getData(URL){
if(this.maxReq <= 0)
// wait until this.maxReq is set to 100 again
// after this.maxReq is set to 100 again return:
return this.http.get(URL).toPromise();
}
To achieve this, I must monitor both the time and the variable maxReq
. The timer should run independently of everything else, counting down from 60 to 0 from the start of the application to the end. When the timer reaches 0, maxReq
needs to be updated and the timer reset to 60 seconds - repeating this process every 60 seconds until the application is closed.
What would be the most effective way to accomplish this task?