Hi Kendall,
Yes that would look good I guess.
You could reduce the number of classes by having only the template:
function ViewTemplate(scope, template, element, model1, model2, model3) {
}
But having a template and a mediator would also work, as long as the mediator does all the framework communication and the template view provides methods to update the view.
I have a similar example on the site, between:
and:
The first example has only one mediator, doing both DOM update and handling framework communications. The second example has one mediator doing only the DOM update and another mediator doing the framework communications and updating the first mediator. Very decoupled.
They are both good, one is more complicated but the code is more decoupled. Only a matter of choice here, and "level of decoupling" you need. There's no need to make things unnecessary complicated though. Adapt the solution to your needs.
About the events versus using methods on object, it is usually a matter of "re-using" actions.
When the data of a model changes:
model --> views/mediators
It is usually good to dispatch an event and have a views and/or mediators listening to it. It makes you free to stop listening, monitor the events, using the same events in new views, and so on.
In the other way:
views/mediators --> model
You can also use events, but it is not a problem at all to use a model method if the model is already accessible.
In this app example, the view doesn't know about the model, it uses events in both ways:
In this one, the view is considered more as a mediator and the model is used directly:
Hope that helps.
Romu