Polling is a technique used in software development to check status of a resource at regular intervals. It is usually used to monitor changes in real time data. It is done by making periodic calls to an api. Some real life applications:
Getting the latest geographic position of a device that updates its location in real time.
Making a request or a command to a device and checking whether the change or command is applied successfully.
Polling is not a good approach for getting updates or changes, because it is not using resources efficiently. Suppose there is no change in the resource you are monitoring. In polling you still need to continue polling in such cases, and this is not an efficient way of using resources.
Instead of polling, an event driven approach could be used. In this case, resource is publishing its state updates to the observers. This is a better usage of resources.
Being said that, sometimes you may not use event-driven approach even it is better. For instance, in one of my project, we used polling until event-driven approach is implemented.
In this blog post, I will show two ways of using polling in RxJava.
1. Way
Keep reading with a 7-day free trial
Subscribe to Android Devs Substack to keep reading this post and get 7 days of free access to the full post archives.