archi
archi copied to clipboard
Better separation between MVP presenter and view
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.
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?