You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There's also boilerplate in writing every Controller name and method in both the Controller subclass and app.js.
How about this instead?
// app.js// was referenced through Controller#viewManagervarviewManager=require('lavaca/mvc/ViewManager');varapp=newApplication(function(){this.router.add({// adaptation of mutualmobile/lavaca-starter app/net/HomeController'/': functionindex(params,state){varmodel=newModel();returnviewManager.load(HomeView,model)// instead of Controller#view().then(function(){// instead of Controller#history, use HTML5 History APIHistory.pushState(state,'Home Page',params.url);});},'/other': function(){}});});
That'd remove mvc/Controller. Controller implementations are usually pretty short (one or two methods), so the above seems doable for all of an application's routes. If a user wanted to split them up, though, they could do something like this:
// app/net/HomeControllerdefine(function(require){varviewManager=require('lavaca/mvc/ViewManager');//just a plain objectreturn{'/': functionindex(params,state){varmodel=newModel();returnviewManager.load(HomeView,model).then(function(){History.pushState(state,'Home Page',params.url);});}};});
The path that a route takes from a url change to a View rendering seems a bit complex to me:
(init/popstate event) -> Router#exec -> Route#exec -> Controller#(method) -> Controller#view -> ViewManager#load -> View#render
There's also boilerplate in writing every Controller name and method in both the Controller subclass and app.js.
How about this instead?
That'd remove mvc/Controller. Controller implementations are usually pretty short (one or two methods), so the above seems doable for all of an application's routes. If a user wanted to split them up, though, they could do something like this:
And then in app.js:
The text was updated successfully, but these errors were encountered: