I have to call API every second to get updated values. But I have some question regarding best practices to handle this
- Do I need to stop the timer if the internet connection is OFF?
- If #1 yes then is it necessary to start API call automatically or should I ask user to try again?
- Assuming API call should resume automatically then how? Should I check reachability every second?
- Since I have to call API every second, so how to handle request timeout and prevent multiple calls for the same request? Do you think I should be worried about this?
Note:
I really want to know best way (standard practices) to do this. I don't want to use third party library.
Better design and optimized way are welcome