mirror of
https://github.com/NuSkooler/enigma-bbs.git
synced 2025-06-10 14:44:40 +02:00
* Use mixin class for ViewController management
This commit is contained in:
parent
bfdc58b90c
commit
40e1e1bea8
3 changed files with 40 additions and 20 deletions
30
core/mod_mixins.js
Normal file
30
core/mod_mixins.js
Normal file
|
@ -0,0 +1,30 @@
|
|||
/* jslint node: true */
|
||||
'use strict';
|
||||
|
||||
var assert = require('assert');
|
||||
|
||||
//
|
||||
// A simple mixin for View Controller management
|
||||
//
|
||||
var ViewControllerManagement = function() {
|
||||
this.initViewControllers = function() {
|
||||
this.viewControllers = {};
|
||||
};
|
||||
|
||||
this.detachViewControllers = function() {
|
||||
var self = this;
|
||||
Object.keys(this.viewControllers).forEach(function vc(name) {
|
||||
self.viewControllers[name].detachClientEvents();
|
||||
});
|
||||
};
|
||||
|
||||
this.addViewController = function(name, vc) {
|
||||
assert(this.viewControllers, 'initViewControllers() has not been called!');
|
||||
assert(!this.viewControllers[name], 'ViewController by the name of \'' + name + '\' already exists!');
|
||||
|
||||
this.viewControllers[name] = vc;
|
||||
return vc;
|
||||
};
|
||||
};
|
||||
|
||||
exports.ViewControllerManagement = ViewControllerManagement;
|
Loading…
Add table
Add a link
Reference in a new issue