read

The idea is to use retryWhen RxJava function to create a new timber observable if it’s a timeout on error

A copy/paste solution can be found in:

It’s just a custom Func1 that receives an Observable to watch for errors with flatMap that should be used with retryWhen operator. For every retry it will wait +1 seconds

Sample

To retry 3 times with 2 initial delay seconds, you must use something like:

myObservable.retryWhen(RetryWithDelayIfTimeout(3, 2))
            .subscribe(...)

Extra

If you want to make it cleaner, add io() and MainThread() management (every io call have it) you can use something like:

and then apply it everywhere:

Written in Kotlin but you can make java versions easy.

Thanks to

Blog Logo

Daniel Gomez Rico


Published

Image

MakinGIANTS

The findings and tips records of an Android-iOS-TheWholeShabang group

Back to Overview