I'm migrating my app to the rxJava2 and would like to clarify some things. In my BasePresenter class I do following:
@Override
public void attachView(T mvpView) {
this.mvpView = mvpView;
compositeDisposable = new CompositeDisposable();
}
@Override
public void detachView() {
compositeDisposable.dispose();
mvpView = null;
}
So if I call compositeDisposable.dispose();
when I detach the view then onNext()
, onError()
or onComplete()
are not going to be called and there is no reason to check isViewAttached()
in onNext()
?
Is this the right way of using CompositeDisposable in the presenter?