Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In MVP, who should handle navigation?

Tags:

mvp

It's my belief that the Presenter is the one responsible for handling the navigation aspect of a MVP application. Is this true or are there exceptions?

like image 349
Bruno Brant Avatar asked Nov 05 '10 22:11

Bruno Brant


1 Answers

I think the view is the only one responsible for the screen navigations. Here we have a good explanation about this "Android-MVP problem" and I have two reasons to think in this way:

1 - Basically for me the screen transitions are not more than a behaviour of views. it belongs of the view state. We know the presenter have to controls the view state through view methods, but is the view that implements this transitions in fact (calling startActivity, for example).

2 - The navigation between screens have some Android SDK dependencies, such as Intents, Bundles, FragmentsManagers, etc... And if you want to use MVP + Clean Architecture (strongly recommended), you "can't" share android dependencies between your presenters, because they should be java only to make the unit tests easier.

like image 194
pablobaldez Avatar answered Jan 01 '23 13:01

pablobaldez