make canon and settings use EventEmitter
This commit is contained in:
parent
81cb24ef17
commit
3d3cef1a6f
2 changed files with 15 additions and 22 deletions
|
|
@ -39,7 +39,7 @@ define(function(require, exports, module) {
|
||||||
|
|
||||||
var console = require('pilot/console');
|
var console = require('pilot/console');
|
||||||
var Trace = require('pilot/stacktrace').Trace;
|
var Trace = require('pilot/stacktrace').Trace;
|
||||||
//var Event = require('events').Event;
|
var MEventEmitter = require("pilot/event_emitter").MEventEmitter;
|
||||||
|
|
||||||
exports.startup = function(data, reason) {
|
exports.startup = function(data, reason) {
|
||||||
if (!data.env || !data.env.settings) {
|
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
|
* Current requirements are around displaying the command line, and provision
|
||||||
|
|
@ -130,7 +130,7 @@ exports.addRequestOutput = function(request) {
|
||||||
exports.requests.shiftObject();
|
exports.requests.shiftObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.addedRequestOutput(request);
|
exports.$dispatchEvent('addedRequestOutput', { request: request });
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -189,10 +189,10 @@ exports.Request = function(options) {
|
||||||
this.end = null;
|
this.end = null;
|
||||||
this.completed = false;
|
this.completed = false;
|
||||||
this.error = 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.
|
* 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
|
* 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.outputs.push(content);
|
||||||
this.changed();
|
this.$dispatchEvent('changed', {});
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
@ -254,11 +254,9 @@ exports.Request.prototype.done = function(content) {
|
||||||
|
|
||||||
if (content) {
|
if (content) {
|
||||||
this.output(content);
|
this.output(content);
|
||||||
} else {
|
|
||||||
this.changed();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.$dispatchEvent('changed', {});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -43,9 +43,10 @@
|
||||||
|
|
||||||
define(function(require, exports, module) {
|
define(function(require, exports, module) {
|
||||||
|
|
||||||
var console = require("util/console");
|
var console = require("pilot/console");
|
||||||
var types = require("types");
|
var oop = require("pilot/oop").oop;
|
||||||
var Event = require("events").Event;
|
var types = require("pilot/types");
|
||||||
|
var MEventEmitter = require("pilot/event_emitter").MEventEmitter;
|
||||||
|
|
||||||
exports.startup = function(data, reason) {
|
exports.startup = function(data, reason) {
|
||||||
// TODO add extension point in new style
|
// TODO add extension point in new style
|
||||||
|
|
@ -141,12 +142,6 @@ function Settings(persister) {
|
||||||
if (persister) {
|
if (persister) {
|
||||||
this.setPersister(persister);
|
this.setPersister(persister);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Event that tells people when a setting has changed.
|
|
||||||
*/
|
|
||||||
// TODO: Fix events
|
|
||||||
// this.settingChange = new Event({ keyElement: 0 });
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Settings.prototype = {
|
Settings.prototype = {
|
||||||
|
|
@ -235,9 +230,7 @@ Settings.prototype = {
|
||||||
persister.persistValue(this, key, value);
|
persister.persistValue(this, key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Inform subscriptions of the change
|
this.$dispatchEvent('settingChange', { key: key, value: value });
|
||||||
// TODO: fix events
|
|
||||||
// this.settingChange(key, converted);
|
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -318,6 +311,8 @@ Settings.prototype = {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
oop.implement(Settings.prototype, MEventEmitter);
|
||||||
|
|
||||||
exports.settings = new Settings(new MemoryPersister());
|
exports.settings = new Settings(new MemoryPersister());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue