I can offer you a really reactive way, not an imperative way.
Paste this code immediately after the subscribe () method:
.retryWhen(retryHandler -> retryHandler.flatMap(nothing -> retrySubject.asObservable())) .subscribe()
Where is the update object:
@NonNull private final PublishSubject<Void> retrySubject = PublishSubject.create();
And when calling snackbar, call this method:
public void update() { retrySubject.onNext(null); }
All of the above retryWhen the method will be literally redone.
Although with this approach, the error will never go down to the subscriber, you can add error correction to the flat retryHandler, but this is another story.
PS sorry, it was Java code with retrolambdas, but you can easily convert it to Kotlin.
source share