In my web app, there are 5 different sections: Blog Display, Blog Entries list, Blog entry editor, blog editor, comments list on one page.
Some of these sections are displayed only when an action is trigged, such as clicking view comments link for a blog entry link should showed the comments list. Clicking edit blog entry link should display the blog entry editor.
In knockout js, is it better to have one big view or multiple views? (terms of performance and maintainability)
I think having multiple view models doesn’t affect performance in comparison to one fat model, but in terms of clean code and convinience i’d go OOP-way with one model.
I mean the following:
All model specific logic is separated and you still can easily subscribe to each of observables between models in MainModel constructor.
I’ve tried both approaches (separate models and one big model) and this one really helps to avoid complexification.
Also, there are still tasks where i’d choose separate models. For example, UI widgets. It’s better to keep their models away from outside as they are self-contained