I am working on sorting out my Javascript code. Currently I have views implement
ID: 646659 • Letter: I
Question
I am working on sorting out my Javascript code. Currently I have views implemented without any Model or collection. Now I working on separating Model from View. So for this transformation, I am planning as follows:
View ---> X <--- | ---> Server
< Client side >
Assumptions:
View will not have any data that is to be loaded form server.
X will talk to server and get the required data. Then X will fire event.
View will listen to events and update themselves accordingly.
X is not an exact replica of some entity on server. X will just take those entities/ data from server and then View can request this data from X.
There will be exactly one X for each View.
Now question is -- What is X called?
Options -- Model, Controller, ViewModel, Presenter, or anything else.
Or Is this very crude thing which can not have terminology?
Explanation / Answer
X is most commonly called a ViewModel. Controllerless MVVM is what your implementation most closely resembles.
If your view is handling the events from X, it's similar to Model-View-Binder, kind of like Knockout.js, maybe without the declarative style.
I wouldn't worry so much about what it's called. Worry about how/if it works.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.