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.97k stars 253 forks source link

Best practice for normal case. (get support.) #131

Closed dhluong90 closed 7 years ago

dhluong90 commented 7 years ago

In my case, I just have an activity with phone number edit text. User input, I send this to server. it's very simple. I don't need restartable feature or something like this. But in current version, someone mark @Deprecated for getView() method. what is the best practice to write my case?

sreejithraman commented 7 years ago

It's not a good idea to use getView() because you aren't guaranteed that the view is not null (it can be null depending on where in the lifecycle the presenter is).

You can however use view() which is an observable that will emit the view when it is/becomes present

kanat commented 7 years ago

You can use the following syntax: add(request() .observeOn(AndroidSchedulers.mainThread()) .subscribe(split( View::showSuccess, View::showError )));

konmik commented 7 years ago

Hi, you can use non-rx presenter, getView is not deprecated there.