Are Web Workers a good replacement if I HAVE to poll an API?


#1

My application uses sockets heavily for real time updates (as well as push notifications). However, in order to guarantee we have at least semi up-to-date data, I typically poll the API on a much longer interval (anywhere from 30 to 60 seconds).

Historically, I have just used $interval to do this, but it seems that is a big no-no.

Would it be worth it to attempt to run a setInterval inside of a web worker to accomplish this in a more performant way?

Additionally? Could I just run the setInterval and then notify ionic to make the call, or would I additionally need to do the work that is possible inside the web worker to make the use worth it?

What is the suggested way of accomplishing polling with a 30-60 interval if not web workers or $interval? The data I am retrieving is not large by any means, but its also not terrible small.