有一个项目流(Observable
),客户代码可以随时取消订阅。默认情况下,Disposable
在客户端取消订阅并终止流时被处置。有没有办法让流保持鲜活?
默认方式:
val subscriber;
val disposable = Observable.concat(obs1, obs2, obs3).subscribe(subscriber);
//later
disposable.dispose();
//obs1 and obs2 are executed, but obs3 not
我在寻找什么
val subscriber;
val subscriberForDisposed;
val disposable = Observable.concat(obs1, obs2, obs3)
.deliverIfDisposed(subscriberForDisposed)
.subscribe(subscriber);
//later
disposable.dispose()
//obs1 and obs2 are executed and delivered to subscriber
//obs3 is executed and delivered to subscriberForDisposed