konmik / nucleus

Nucleus is an Android library, which utilizes the Model-View-Presenter pattern to properly connect background tasks with visual parts of an application.
MIT License
1.98k stars 253 forks source link

How to get view in presenter? #120

Closed bailyzheng closed 7 years ago

bailyzheng commented 7 years ago

In MVP model, view and presenter can known each other. Nucleus can get presenter by getPresenter(). How to get view in presenter class?

TWiStErRob commented 7 years ago

How about getView()?

yankeppey commented 7 years ago

In my project I use a method in base presenter class

    public void deliver(@NonNull Action1<? super View> onNext, @NonNull Action1<Throwable> onError) {
        view().filter(v -> v != null)
                .take(1)
                .subscribe(onNext, onError);
    }

which delivers a desired action to View as soon as possible.

bailyzheng commented 7 years ago

@yankeppey right, thank you. I think get view is not recommend in presenter by the author. So view and presenter is decoupling.