make canon and settings use EventEmitter

This commit is contained in:
Joe Walker 2010-11-23 15:38:32 +00:00
commit 3d3cef1a6f
2 changed files with 15 additions and 22 deletions

View file

@ -39,7 +39,7 @@ define(function(require, exports, module) {
var console = require('pilot/console');
var Trace = require('pilot/stacktrace').Trace;
//var Event = require('events').Event;
var MEventEmitter = require("pilot/event_emitter").MEventEmitter;
exports.startup = function(data, reason) {
if (!data.env || !data.env.settings) {
@ -91,7 +91,7 @@ exports.Canon.prototype = {
}
};
// exports.addedRequestOutput = new Event();
oop.implement(exports, MEventEmitter);
/**
* Current requirements are around displaying the command line, and provision
@ -130,7 +130,7 @@ exports.addRequestOutput = function(request) {
exports.requests.shiftObject();
}
exports.addedRequestOutput(request);
exports.$dispatchEvent('addedRequestOutput', { request: request });
};
/**
@ -189,10 +189,10 @@ exports.Request = function(options) {
this.end = null;
this.completed = false;
this.error = false;
// this.changed = new Event();
};
oop.implement(exports.Request.prototype, MEventEmitter);
/**
* Lazy init to register with the history should only be done on output.
* init() is expensive, and won't be used in the majority of cases
@ -238,7 +238,7 @@ exports.Request.prototype.output = function(content) {
}
this.outputs.push(content);
this.changed();
this.$dispatchEvent('changed', {});
return this;
};
@ -254,11 +254,9 @@ exports.Request.prototype.done = function(content) {
if (content) {
this.output(content);
} else {
this.changed();
}
this.$dispatchEvent('changed', {});
};
});