archi icon indicating copy to clipboard operation
archi copied to clipboard

Better separation between MVP presenter and view

Open davidschreiber opened this issue 8 years ago • 1 comments

In the MVP example the view directly issues commands on the presenter, for example the MainActivity directly calls MainPresenter#loadRepositories whereas it should rather use a passive callback like Presenter#onUsernameSubmitted. The main reason for this is to hand over navigation responsibility to the presenter away from the view (which should be a dumb view).

I've created this issue for discussion, since this is obviously a matter of architecture style and code separation.

davidschreiber avatar Jul 03 '16 18:07 davidschreiber

Hi David, I kind of agree with you that presenter methods should be named differently using callback-like name. However, there is cases where the presenters have to perform an action that hasn't necessarily been triggered by the user. For example, when the activity is created the presenter has to load and present some data. Do you think is better to have a separate method in the presenter like loadData() and call that from Activity.onCreate(), or simply triggering that initial call from the attach(MvpView view) method in the Presenter?

ivacf avatar Jul 04 '16 13:07 ivacf