client/general: refactor control flow

- Controller lifetime is bound to route lifetime
- View lifetime is bound to controller lifetime
- Control lifetime is bound to view lifetime
- Enhanced event dispatching
- Enhanced responsiveness in some places
- Views communicate user input to controllers via new event system
This commit is contained in:
rr-
2016-06-14 10:31:48 +02:00
parent c74f06da35
commit 54e3099c56
68 changed files with 1755 additions and 1561 deletions

View File

@ -1,35 +1,23 @@
'use strict';
const router = require('../router.js');
const TopNavigation = require('../models/top_navigation.js');
const topNavigation = require('../models/top_navigation.js');
const HelpView = require('../views/help_view.js');
class HelpController {
constructor() {
this._helpView = new HelpView();
}
registerRoutes() {
router.enter(
'/help',
(ctx, next) => { this._showHelpRoute(); });
router.enter(
'/help/:section',
(ctx, next) => { this._showHelpRoute(ctx.params.section); });
router.enter(
'/help/:section/:subsection',
(ctx, next) => {
this._showHelpRoute(ctx.params.section, ctx.params.subsection);
});
}
_showHelpRoute(section, subsection) {
TopNavigation.activate('help');
this._helpView.render({
section: section,
subsection: subsection,
});
constructor(section, subsection) {
topNavigation.activate('help');
this._helpView = new HelpView(section, subsection);
}
}
module.exports = new HelpController();
module.exports = router => {
router.enter('/help', (ctx, next) => {
new HelpController();
});
router.enter('/help/:section', (ctx, next) => {
new HelpController(ctx.params.section);
});
router.enter('/help/:section/:subsection', (ctx, next) => {
new HelpController(ctx.params.section, ctx.params.subsection);
});
};