1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Fix node emitter

This commit is contained in:
Nick O'Leary 2014-05-15 20:55:01 +01:00
parent 820ca4475d
commit 525321ec7f

View File

@ -25,7 +25,6 @@ var comms = require("../comms");
function Node(n) { function Node(n) {
this.id = n.id; this.id = n.id;
this._events = new EventEmitter();
flows.add(this); flows.add(this);
this.type = n.type; this.type = n.type;
if (n.name) { if (n.name) {
@ -34,6 +33,10 @@ function Node(n) {
this.wires = n.wires||[]; this.wires = n.wires||[];
} }
util.inherits(Node,EventEmitter);
Node.prototype._on = Node.prototype.on;
Node.prototype.on = function(event,callback) { Node.prototype.on = function(event,callback) {
var node = this; var node = this;
if (event == "close") { if (event == "close") {
@ -48,12 +51,9 @@ Node.prototype.on = function(event,callback) {
} else { } else {
this.close = callback; this.close = callback;
} }
} else {
this._on(event,callback);
} }
this._events.on(event,callback);
}
Node.prototype.emit = function(event,args) {
this._events.emit(event,args);
} }
Node.prototype.close = function() { Node.prototype.close = function() {