Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* e.g.
- var actions = {
- 'someAction1': function() {
- console.log('someAction1')
- }.
- 'someAction2': function() {
- console.log('someAction1')
- }
- },
- // extend however you want. I'm using lodash here.
- mainController = _.extend(new SimpleController(), {
- actions: actions,
- onBeforeAction: function() {
- log('onBeforeAction');
- },
- onAfterAction: function() {
- log('onAfterAction');
- }
- });
- */
- var SimpleController = (function() {
- 'use strict';
- function SimpleController() {
- }
- SimpleController.prototype.handleAction = function(options) {
- this.onBeforeAction(arguments);
- this.actions[options.action].apply(this, [options]);
- this.onAfterAction(arguments);
- }
- SimpleController.prototype.initialize = function() {};
- SimpleController.prototype.actions = {};
- SimpleController.prototype.onBeforeAction = function() {
- };
- SimpleController.prototype.onAfterAction = function() {
- };
- SimpleController.prototype.dispose = function() {};
- return SimpleController;
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement