When creating an Observable like this:
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
is called, doOnDispose
is not called.
Why is that?