0

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?

Vadims Savjolovs
  • 2,618
  • 1
  • 26
  • 51
  • You don't have to check if you use standard static method (Observable.just/create/from) to create Observables. They check inside it already. – Phoenix Wang Apr 03 '17 at 12:56

1 Answers1

1

Yes, that is correct. CompositeDisposable is essentially what CompositeSubscription was in the previous version of rxJava.

GreyBeardedGeek
  • 29,460
  • 2
  • 47
  • 67