zsiegel / rx-mvp-android

A basic project demonstrating some uses of RxJava with the Model-View-Presenter pattern on android

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

In UserPresenter, subscription class variable is never set.

Laimiux opened this issue · comments

https://github.com/zsiegel/rx-mvp-android/blob/master/core-lib/src/main/java/com/zsiegel/core/presenter/UserPresenter.java

Shouldn't this

    @Override
    public void start() {
        getObservable().subscribe(getSubscriber());
    }

be

    @Override
    public void start() {
        subscription = getObservable().subscribe(getSubscriber());
    }

and this

   @Override
    public void finish() {
        subscription.unsubscribe();
    }

be

   @Override
    public void finish() {
        subscription.unsubscribe();
        subscription = Subscriptions.empty();
    }

Yes this is a bug. Thanks for pointing it out!

I have update the code just now. One thing to not is we usually dont re-use presenters so we dont reset to Subscriptions.empty() but if you want to cache them its a valid approach.