Reputation: 1441
I would like to delay the subscription to dispatch by XXXX time regardless of error or success. With the following code the delay is working for the success scenario only. Please help me so that it can wait XXXX time always.
serviceRepository.getService()
.retry(0)
.map(value -> {
total = XXXX;
return value;
})
.observeOn(schedulerProvider.mainThread())
.delaySubscription(total, TimeUnit.MILLISECONDS)
.subscribeWith(return new DisposableSingleObserver<ServiceResponse>() {
@Override
public void onSuccess(ServiceResponse serviceResponse) {
}
@Override
public void onError(Throwable e) {
}
});
Upvotes: 1
Views: 500
Reputation: 25573
Move the delaySubscription
before the retry
call. RxJava operators operate upwards, so your delay applies to the original subscription to the retry, but not the additional subscription in the error case, since retry only knows what exists upstream.
Upvotes: 1