Using
ANGULAR
I would like http.get to frequently pull data from an API, and can’t find a viable solution. The API is providing minute by minute traffic data, and I would like Angular to reflect the updates.
At the moment i am using interval from rxjs to refresh the Get request, but that’s crashing the browser. This turns out, is not a suitable way do get this done. It is memory intensive.
interval(3000).subscribe(x => { http.get('api.link')});
What solution is there that I could get this done conservatively ?
2
Answers
i handle these situations with following code:
Probably the request sometimes takes more than 3 sec.
You need to use concatMap to ensure that the next request will only be fired after the current one is completed, ensuring that requests do not overlap