I am developing web apps using the Model-View-ViewModel approach with Knockout.js. After reading on the original introduction of MVVM by John Gossman, I realized that my ViewModel always contains ALL the app's logic, not only UI logic, but everything.
I've read somewhere that with Knockout, the model is considered the database or generally the data on the server. But according to MVC, the model also contains functions which do some processing with that data and are not UI-related.
So I wondered if it would be reasonable to have a separate Model object independent from the ViewModel object? The idea behind this would be that the ViewModel would contain UI logic only (as intended by Gossman) and the Model would contain business logic only (as in MVC), which has nothing to do with the actual View. Example:
var viewModel = {
hint: ko.observable("Idle"), //text visible in the View
buttonClicked: function () {
this.hint("doing stuff");
model.doStuff();
this.hint("done");
}
};
var model = {
doStuff: function () {
//business logic, UI independent
}
};
Is there a recommendation or "best practice" which can be derived from the MVVM pattern definition?