Reputation: 1221
Following this article There are two schools of thought with regard to whether the View interacts directly with the Model or not.
I'm interested in the case where View don't interact with Model. If only Controller knows about View but not View knows about Controller we can easily update View with Model data (write some text, for ex.) by calling View and Model methods in Controller.
But how could Controller and Model react to View changes (button push, for ex.) if View don't know about Controller or Model?
Upvotes: 0
Views: 35
Reputation: 530
-One solution-
One way to make 2 objects communicate with loose coupling (in your case views don't know about controller and vice-versa) it to use a "messenger" pattern.
The 'messenger' is an object known by all the others. Using the 'messenger' object:
In this way, a model can react to a specific view's event because it is registered into the messenger.
There is a full example here (C# code): Light messenger pattern
Tell me if it s what you were looking for...
Upvotes: 1