I'm having quite a bit of trouble trying to understand this pattern. At work we are implementing MVP with passive views. We are using WinForms.
Say we have a view of Clients, which reperesents a Model Clients and we have a table in our database called Clients. Clients can have name, and city.
We also have a view for Cities, which is a simple add, edit and remove, it also represents a model City, and a table City.
Now in our view of Clients, we want to let the user add a new city, so in the view, we open another view, the Cities view, the user then creates a new city.
From the Clients view, I want to see what City the user added, how is that possible? Shall the view return something?
(I want to have it in memory, not persist anything to the database when adding a city, I just want the model of the city)
I think returning a model and viewing models from the view is not MVP. How can I do it then?
One view opening up another is perfectly reasonable, but I personally don't favour the view returning a value to be used by the caller. What if other views needed to have access to this new city?
See my answer here: MVP Communication between presenters? for an example of using pub/sub to achieve your goal.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.