diff --git a/lib/core/events.js b/lib/core/events.js index f7f055fc8..c561f0008 100644 --- a/lib/core/events.js +++ b/lib/core/events.js @@ -29,23 +29,26 @@ EventEmitter.prototype.setHandler = function(requestName, cb) { return _setHandler.call(this, requestName, cb); }; -EventEmitter.prototype.request = function(requestName, cb) { +EventEmitter.prototype.request = function() { + let requestName = arguments[0]; + let other_args = [].slice.call(arguments, 1); + log("requesting: ", requestName); warnIfLegacy(requestName); - return this.emit('request:' + requestName, cb); + return this.emit('request:' + requestName, ...other_args); }; EventEmitter.prototype.setCommandHandler = function(requestName, cb) { log("setting command handler for: ", requestName); return this.on('request:' + requestName, function(_cb) { - cb.call(this, _cb); + cb.call(this, ...arguments); }); }; EventEmitter.prototype.setCommandHandlerOnce = function(requestName, cb) { log("setting command handler for: ", requestName); return this.once('request:' + requestName, function(_cb) { - cb.call(this, _cb); + cb.call(this, ...arguments); }); };