Advertisement
Guest User

Untitled

a guest
Apr 19th, 2015
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. /* e.g.
  2. var actions = {
  3. 'someAction1': function() {
  4. console.log('someAction1')
  5. }.
  6.  
  7. 'someAction2': function() {
  8. console.log('someAction1')
  9. }
  10. },
  11.  
  12. // extend however you want. I'm using lodash here.
  13. mainController = _.extend(new SimpleController(), {
  14. actions: actions,
  15.  
  16. onBeforeAction: function() {
  17. log('onBeforeAction');
  18. },
  19.  
  20. onAfterAction: function() {
  21. log('onAfterAction');
  22. }
  23. });
  24. */
  25.  
  26. var SimpleController = (function() {
  27. 'use strict';
  28.  
  29. function SimpleController() {
  30. }
  31.  
  32. SimpleController.prototype.handleAction = function(options) {
  33. this.onBeforeAction(arguments);
  34. this.actions[options.action].apply(this, [options]);
  35. this.onAfterAction(arguments);
  36. }
  37.  
  38. SimpleController.prototype.initialize = function() {};
  39.  
  40. SimpleController.prototype.actions = {};
  41.  
  42. SimpleController.prototype.onBeforeAction = function() {
  43. };
  44.  
  45. SimpleController.prototype.onAfterAction = function() {
  46. };
  47.  
  48. SimpleController.prototype.dispose = function() {};
  49.  
  50. return SimpleController;
  51.  
  52. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement