Last active
December 10, 2015 03:08
-
-
Save anatoliychakkaev/4372889 to your computer and use it in GitHub Desktop.
Another way of controllers describing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Application = module.exports = function Application(init) { | |
init.before(function protectFromForgery(c) { | |
c.protectFromForgery('74be5145ccc6b731ee2d6f08990cc4f43c2bc800'); | |
}); | |
}; | |
Application.prototype.someAction = function (c) { | |
c.send('hello'); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Application = require('./application'); | |
var Driver = module.exports = function Driver(init) { | |
Application.call(this, init); | |
init.before(function think(c) { | |
console.log('thinking'); | |
c.next(); | |
}, {only: 'accelerate'}); | |
}; | |
require('util').inherits(Driver, Application); | |
Driver.prototype.accelerate = function (c) { | |
c.send('accelerate'); | |
}; | |
Driver.prototype.brake = function (c) { | |
c.send('brake'); | |
}; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment