retrofit - Rx Network Polling & Immediately getting first result -


i want poll service application, can refresh data periodically (~15 minutes). however, same data needed on startup. i'm using retrofit & rxandroid.

i can network data (or whenever call returns, rather), , have been working on doing repeating call this:

    return mnetworker.getinitializationproperites(deviceid)             .observeon(schedulers.io()) // database i/o need done             .subscribeon(schedulers.io())             .delay(20l, timeunit.seconds) // 20 seconds testing             .repeat()             .subscribe(onnext, rxerrorhandler.handle(), oncomplete); 

this method (and others using timer , interval) time interval correct, deliver result late. particularly, in above, know webservice hit immediately, yet waits 20 seconds emit result.

is there way can combine ideas of getting first result asap & schedule repeat indefinitely? other thought create 2 different observables , subscribe them separately, seems i'm missing something.

instead of starting network observable , repeating it, start timer observable , flatmap network observable, like

observable.timer(0l, 20l, timeunit.seconds).flatmap(i -> donetworkrequest()) 

Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

datatable - Matlab struct computations -