I want to achieve the following in angular 6:
while(true) {
- call API
- process the response
- wait 1 second
}
I tried the TimerObservable, but failed to make wait 1 second after the request has finished because it is asynchronous. The purpose is to not call the api when requests take a long time but to have the latests response quick when requests take short time to finish.
My Code is:
TimerObservable.create(0, 1000)
.subscribe(() => {
this.api.getData().subscribe(
response => {
console.log(response);
}
);
});