Retry Network Calls In Rxjava
How to make retry network calls when network errors appear with rxJava in Android. Here is my rxJave code: RxTextView.textChanges(searchInput) .debounce(500, TimeUnit.M
Solution 1:
Make a PublishSubject
and add retryWhen(subject)
.
Then listen for changes to connectivity and when the network becomes available call subject.onNext(null)
and if your rx-chain is stalling on that it will retry.
.switchMap(query -> getTypedPlaces(query).retryWhen(subject))
other notes...
.subscribeOn(AndroidSchedulers.mainThread())
is superfluous as the events on the TextView originate from the mainThread.
.observeOn(Schedulers.io())
may not be necessary or you could just set the scheduler specifically in debounce.
Post a Comment for "Retry Network Calls In Rxjava"