为什么不调用 doOnDispose?
创建可观察量时,如下所示:
public void foo() {
Observable observable = Observable.fromCallable(() -> {
bar();
return "";
})
.doOnSubscribe(disposable -> System.out.println("onSubscribe"))
.doOnDispose(() -> System.out.println("onDispose"));
Disposable disposable = observable.subscribe();
disposable.dispose();
}
private void bar() {
System.out.println("bar");
}
doOnSubcribe
被叫,不叫。doOnDispose
为什么?