MVC - M - V Relation ?
I would like to get others' opinions before coding a certain part of my app.
It is a MVC framework based application with only custom Models, Views and Controllers.
Some Models expose "one dynamic object" to their View.
The View refers to contents of this "one dynamic object's" properties which are Value Objects.
When a new property is ADDED to the Model, it dispatches a "MODEL_CHANGED" event and the View reflects the change.
when an existing property is REMOVED from the Model or the whole "one dynamic object", which the View refers to, is temporarily set to "null" during update, I expect to get "null Object" errors from the View at runtime.
My idea of a solution is to let the Model dispatch a
"MODEL_CHANGING" event -> causing
the View to resets itself and dispatch a
"VIEW_RESET" event -> causing
the Model to update the exposed "one dynamic object" and just then dispatch the
"MODEL_CHANGED" event -> causing
the View to render the Models content.
What I do not like about my solution is, that the Model and the View are listening to EACH-OTHER rather than just the View listening to the Model.
Any ideas or advices?