Hi All, I am new to Rx world and stuck into implementing polling mechanism in RxJava2 for Android. I have to call a webservice max x times and at the interval of y seconds on the success or failure of that webservice. By interval I mean wait for y seconds before making another call. For network call call back mechanism is being used.I also need to show UI based on servive response.Can someone here can help me in implementing the same? It would be highly appreciated.
c
Casey Kulm
09/28/2018, 3:14 PM
Using Firebase for something like this is much more performant, and more importantly less error prone
Casey Kulm
09/28/2018, 3:14 PM
Or some cloud messaging solution
j
Jeremy Rempel
09/28/2018, 3:17 PM
You can use interval operator
Jeremy Rempel
09/28/2018, 3:19 PM
something like JobScheduler/WorkManager might be more appropriate though
u
ursus
09/28/2018, 4:43 PM
Observable.interval { }.flatmap { requestObservable }
good luck
c
Casey Kulm
09/28/2018, 4:57 PM
When I say error prone, I mean polling gone wrong can wreak havoc on your server costs, and cloud messaging is going to respond much faster than polling anyways.
j
Jeremy Rempel
09/28/2018, 6:04 PM
@Casey Kulm I think you are generally correct but unsure about op's requirements. firebase is a complete solution. My current project for example firebase was not a option for various reasons