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

Allow node emitted events to have multiple arguments

This is fixing a regression introduced in 1.0 where a custom
`Node.emit` function was added that could only handle a single
argument.
This commit is contained in:
Nick O'Leary 2019-10-10 16:35:12 +01:00
parent 053e3ba923
commit 547e7a1b21
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9

View File

@ -169,20 +169,20 @@ Node.prototype._emit = Node.prototype.emit;
/** /**
* Emit an event to all registered listeners. * Emit an event to all registered listeners.
*/ */
Node.prototype.emit = function(event,arg) { Node.prototype.emit = function(event, ...args) {
var node = this; var node = this;
if (event === "input") { if (event === "input") {
// When Pluggable Message Routing arrives, this will be called from // When Pluggable Message Routing arrives, this will be called from
// that and will already be sync/async depending on the router. // that and will already be sync/async depending on the router.
if (this._asyncDelivery) { if (this._asyncDelivery) {
setImmediate(function() { setImmediate(function() {
node._emitInput(arg); node._emitInput.apply(node,args);
}); });
} else { } else {
this._emitInput(arg); this._emitInput.apply(this,args);
} }
} else { } else {
this._emit(event,arg); this._emit.apply(this,arguments);
} }
} }