-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Closed
Description
Hello
I am not sure this is an issue, I would rather say this is a question.
I have noticed a different behavior between RxJava 1.x and RxJava 2.x
When an observable is completed, with RxJava 1.x subscriptions get unsubscribed:
BehaviorSubject<Object> subject = BehaviorSubject.create();
Subscription subscription = subject.subscribe();
subject.onCompleted();
System.out.println(subscription.isUnsubscribed()); // display true
However with RxJava2, the subscription is not disposed when the observable is completed:
Disposable subscription = null;
@Test
public void test() {
BehaviorSubject subject = BehaviorSubject.create();
Observer<? super String> observer = new Observer<String>() {
public void onSubscribe(Disposable d) {
subscription = d;
}
...
};
subject.subscribe(observer);
subject.onComplete();
System.out.println(subscription.isDisposed()); // display false
}
Is it a wanted behavior? If so is this behavior documented somewhere?
Thanks a lot for your help