gpt4 book ai didi

java - retryWhen 后未调用 doOnCompleted

转载 作者:太空宇宙 更新时间:2023-11-04 12:38:14 24 4
gpt4 key购买 nike

我有这样的东西:

            service.getStuff()
.map(...)
.observeOn(AndroidSchedulers.mainThread())
.retryWhen(errors -> errors.flatMap(t -> {
return otherObservable.doOnNext(someSideEffect);
}))
.doOnCompleted(() -> onComplete())
.subscribe(onNext() , onError());

执行onNext(),并在service.getStuff()的原始可观察对象上调用onComplete()

问题:doOnCompleted() 不执行。

原始可观察值(service.getStuff)是:

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");
}
});
}
}

最佳答案

我不完全明白发生了什么,但在找到this similar discussion之后我在没有 flatMap 的情况下重新实现了它并且它有效:

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

关于java - retryWhen 后未调用 doOnCompleted,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37093388/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com