重试后没有调用doOnCompletedWhen

时间:2016-05-07 20:30:48

标签: java rx-java rx-android

我有这样的事情:

            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}}

1 个答案:

答案 0 :(得分:0)

我不完全理解发生了什么,但在找到this similar discussion后我没有使用flatMap重新实现它并且它有效:

.retryWhen(errors -> errors.zipWith(otherObservable, dummyZipFunction));