是否可以重新订阅 Retrofit 2 observable?

Is it possible to re-subscribe to a Retrofit 2 observable?

我正在将 Retrofit 2 与 RxAndroid 一起使用,并且我想在配置更改期间保持请求继续进行。我认为我可以按照 this blog post 和我见过的其他人的描述使用 Observable.cache() 来完成,但以下流程会导致 InterruptedException

Observable<Result<List<Post>>> request = 
        postService.index(page).cache();
Subscription subscribeOne = request.subscribe();
subscribeOne.unsubscribe();
Subscription subscribeTwo = request.subscribe();

我很确定 Retrofit 源代码中的以下代码负责在调用 unsubscribe 时取消请求。

// Attempt to cancel the call if it is still in-flight on unsubscription.
subscriber.add(Subscriptions.create(new Action0() {
    @Override public void call() {
        call.cancel();
    }
}));

不退订使一切正常,但这可能会导致泄漏。有没有人设法用 Retrofit 2 处理配置更改?我可以使用其他方法吗?

感谢 /u/insane-cabbage 的提示,我设法用 BehaviourSubject 实现了这一点(安全地封装在演示者中)。这是流程的示例。

BehaviorSubject<String> subject = BehaviorSubject.create();

/** User loads view and network request begins */
Observable.just("value")
        .delay(200, TimeUnit.MILLISECONDS)
        .subscribeOn(Schedulers.newThread())
        .subscribe(subject::onNext);

Subscription portraitSub = subject.subscribe(
        s -> System.out.println("Portrait: " + s));

/** onDestroy() */
portraitSub.unsubscribe();

/** Rotating... */
Thread.sleep(300);

/** onRestoreInstanceState() **/
Subscription landscapeSub = subject.subscribe(
        s -> System.out.println("Landscape: " + s));

/** Output */
> Landscape: value

我有一个工作示例 RxApp that uses AsyncSubject to implement cache for network request and the code shows how to subscribe to a pending request. I'm a bit confused with Rx subjects as on the other they seem pretty handy but on the other hand it's recommended that they are to be used only in very seldom cases e.g. To Use Subject Or Not To Use Subject?。如果像我的示例中那样使用它们,如果有人可以解释真正的问题是什么,那就太好了。