Skip to content

Instantly share code, notes, and snippets.

@anatoliychakkaev
Last active December 10, 2015 03:08
Show Gist options
  • Save anatoliychakkaev/4372854 to your computer and use it in GitHub Desktop.
Save anatoliychakkaev/4372854 to your computer and use it in GitHub Desktop.
Commonjs-style controller for 1602/kontroller
var Driver = module.exports = require('kontroller').BaseController.constructClass();
Driver.init = function (c) {
c.extendWith(require('./application'));
};
Driver.before(function think(c) {
this.allok = true;
c.next();
}, {only: 'accelerate'});
Driver.before(function panic(c) {
this.inpanic = true;
c.next();
}, {only: 'brake'});
// define action
Driver.actions.accelerate = function accelerate(c) {
c.send('accelerating!');
};
// and another one
Driver.actions.brake = function brake(c) {
c.send('braking!');
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment