1
0
mirror of https://github.com/JuanCanham/HackMyResume.git synced 2024-12-23 05:37:23 +00:00

Verbs are event emitters.

Let verbs source events through EventEmitter. Using aggregation is a bit
simpler here than extending because of the Resig "Class" stuff.
This commit is contained in:
hacksalot 2016-01-09 08:12:55 -05:00
parent 43564bf380
commit d77b484e55
2 changed files with 15 additions and 3 deletions

View File

@ -11,7 +11,9 @@ Definition of the Verb class.
// Use J. Resig's nifty class implementation
var Class = require( '../utils/class' );
var Class = require( '../utils/class' )
, EVENTS = require('events');
@ -21,8 +23,14 @@ Definition of the Verb class.
*/
var Verb = module.exports = Class.extend({
init: function() {
this.emitter = new EVENTS.EventEmitter();
},
on: function() {
this.emitter.on.apply( this.emitter, arguments );
}
});
}());

View File

@ -32,6 +32,10 @@ Implementation of the 'generate' verb for HackMyResume.
var BuildVerb = module.exports = Verb.extend({
init: function() {
this._super();
},
invoke: function() {
build.apply( this, arguments );
}