我有这样的事情:
service.getStuff()
.map(...)
.observeOn(AndroidSchedulers.mainThread())
.retryWhen(errors -> errors.flatMap(t -> {
return otherObservable.doOnNext(someSideEffect);
}))
.doOnCompleted(() -> onComplete())
.subscribe(onNext() , onError());
onNext()
执行,onComplete()
上的service.getStuff()
来自doOnCompleted()
问题:Observable.create(new Observable.OnSubscribe<InputStream>() {
@Override
public void call(final Subscriber<? super InputStream> subscriber) {
call.enqueue(new Callback() {
@Override
public void onFailure(Call call, IOException e) {
subscriber.onError(e);
}
@Override
public void onResponse(Call call, Response response) throws IOException {
subscriber.onNext(response.body().byteStream());
Log.d("HTTP", "calling complete");
subscriber.onCompleted();
Log.d("HTTP", "called complete");
}
});
}
}
未执行。
原始的observable(service.getStuff)是:
{{1}}
答案 0 :(得分:0)
我不完全理解发生了什么,但在找到this similar discussion后我没有使用flatMap重新实现它并且它有效:
.retryWhen(errors -> errors.zipWith(otherObservable, dummyZipFunction));