If the onComplete call is made for a RxJava Subject, do i have to manually unsubscribe again?
Subjects are a relatively thin layer on top of an Observable that allow you to feed onNext()
, onCompleted()
and onError()
calls from a source external to the Observable. Their unsubscribe behavior is the same as an Observable. If onCompleted()
or onError()
are called on the Subject, the subscribers will be unsubscribed. No need to call unsubscribe()
on the subscription returned from Observable.subscribe()
.
For a ReplaySubject
, note that resources will not be cleaned up until it is garbage collected. Even after onCompleted()
has been called on a ReplaySubject
, a subscriber can still subscribe and it will receive all of the original onNext()
, onCompleted()
or onError()
calls that were made previous to subscribing.