I am trying to implement MVP with Passive View for the first time, but I am a little confused as to who is notifying whom in this pattern. I understand that views notify the presenter if they get changed, and the presenter in turn notifies everyone else (other views and the model).
Now, in my case I have multiple views, and I also have a model that can get changed outside of the UI. The following two scenarios can happen:
View[i] gets changed and notifies Presenter. Presenter needs to notify all other Views and Model, but not View[i]. Furthermore, neither Views nor Model may send out change notifications to Presenter even though they just got modified (otherwise there would be an infinite loop of events).
Model gets changed and notifies Presenter. Presenter needs to notify all views, but not Model. But none of the Views may send out change notifications to Presenter even though it just got modified.
How will the presenter whom to notify and whom not? And how does the model know if it needs to send out change notifications? After all, it just got modified, but it doesn't necessarily know by whom.
One possibility is to let everyone (model, views and presenter) freely send out change notifications, but to store a reference to the object that originally triggered the change inside the notification (thereby encapsulating the notification in an event object). Every object then only sends out notifications if he is not the original trigger of the change. But is there a simpler, cleaner way of doing it?