我们如何在不明确告诉路由的控制器方法启动/停止每个模块的情况下处理路由之间的启动/停止模块。
var AppRouterController = {
index: function() {
// Start only modules I need for this route here
// in this case, HomeApp only
App.module('HomeApp').start();
// Stop all modules that should not be running for this route
// The idea, being that not everyone has to come to the index route first
// They could have been to many other routes with many different modules starting at each route before here
App.module('Module1').stop();
App.module('ModuleInfinity').stop();
// ...
// ...
// This could get tedious, expensive, and there has to be a better way.
},
someOtherRouteMethod: function() {
// Do it all over again
}
}
我知道我在这里做错了,希望不是从根本上,但如果有更好的方法,请告诉我。模块管理将成为该项目的关键,因为它将主要在平板设备上运行。