I'm currently using the Laravel PHP MVC Framework to develop a web application; and it's going along quite nicely. I'm very comfortable with the expectations of the framework and how my application should be structured. This is not a problem.
My problem is with the front end, UI/interaction side. I am using Knockout.js & jQuery to encapsulate a lot of front end UI & data interaction; and I'm not sure I'm using the former correctly.
SomeSinglePageViewModel.js file to handle this.
What I am not to sure about is how, or even whether, Knockout.js view models should be used across/between pages. Right now, I'm creating a ViewModel for nearly every CRUD operation and page in my application. Is this correct design?
For example, I'll have a
CreateUserViewModel.js for my /User/Signup page, and a
EditUserViewModel.js for my /User/Edit page; and a `HomePageViewModel.js for the application landing page to control that UI. Is it correct to follow a "one viewmodel per page" philosophy? Or am I doing it wrong? Is it meant to be a "one viewmodel per data model" philosophy?
Where do I draw the line between ViewModels? Do I risk encapsulating too much functionality into one object, or do I risk separating everything out too broadly and creating duplicative files? How have you structured your Knockout.js ViewModels?