I have the following code:
Single<Item> update(...) {
...
return Single.create(subscriber -> aCall.execute(..) {
public void onResponse(..){
subscriber.onSuccess(..)
}
public void onError() {
if(shouldReset) {
subscriber.unsubscribe();
} else {
subscriber.onError();
}
}
}));
}
When calling the method:
update(..)
.doOnSubscribe(counter++)
.doAfterTerminate(counter--)
.subscribe();
I've noticed that the counter is never decreased if subscriber.unsubscribe();
is called. Why is that?
If I change from doAfterTerminate()
in doOnUnsubscribe()
, the counter is decreased.