Last active
December 10, 2015 03:08
-
-
Save anatoliychakkaev/4372854 to your computer and use it in GitHub Desktop.
Commonjs-style controller for 1602/kontroller
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 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