As I understand, when we use MVP we move all presentation logic to the Presenter. But we don't want to let the Presenter know about view implementation, so how can we navigate to another screen in the application? How do you manage application flow on your real application?
I assume that you mean another screen that has its own MVP-pair?
I was thinking about that case this morning, my solution will probably be that there is a Coordinator knows the Presenter and the MVP-pair that needs to be opened. That one opens the new presenter+view and, when finished, optionally calls a method on the first presenter with the results.
In that way, the first MVP doesn't have to know anything about the new screen, they only fire an event. The logic for opening the second window and communicating back is entirely contained in the Coordinator.
Using some navigator interface, for example:
interface INavigator
{
void MoveTo (string screenName);
void MoveTo (string screenName, NavigationParameters parameters);
}
Each presenter would then have an instance of this navigator passed in the constructor. This way the navigation is decoupled both from the presenter and from individual views.
You can have the mapping between screen names and actual Form classes defined in a configuration.
It's a Method on the view. So you would have an abstract method, like ShowCustomerForm(), for example, and the implementation for WinForms would be CustomerForm.Show (or whatever it is in WinForms) and in WebForms it would be Response.Redirict(CustomerForm.aspx).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With