Bug 1454792 - Use arrow functions instead of bind in protocol.js. r=jryans draft
authorAlexandre Poirot <poirot.alex@gmail.com>
Mon, 16 Apr 2018 09:30:43 -0700
changeset 784231 854a98f364b347d193d130d811417c47162d1020
parent 784230 23da050bfed71740d3e5dcb09f05523b8612f023
child 784232 07203e86c7c48d5894f860c9a120cd6e74f24f0b
push id106883
push userbmo:poirot.alex@gmail.com
push dateWed, 18 Apr 2018 09:44:52 +0000
reviewersjryans
bugs1454792
milestone61.0a1
Bug 1454792 - Use arrow functions instead of bind in protocol.js. r=jryans MozReview-Commit-ID: 8pOL86G3ff5
devtools/shared/protocol.js
--- a/devtools/shared/protocol.js
+++ b/devtools/shared/protocol.js
@@ -934,19 +934,18 @@ exports.Pool = Pool;
  */
 var Actor = function(conn) {
   Pool.call(this, conn);
 
   // Forward events to the connection.
   if (this._actorSpec && this._actorSpec.events) {
     for (let key of this._actorSpec.events.keys()) {
       let name = key;
-      let sendEvent = this._sendEvent.bind(this, name);
       this.on(name, (...args) => {
-        sendEvent.apply(null, args);
+        this._sendEvent(name, ...args);
       });
     }
   }
 };
 
 Actor.prototype = extend(Pool.prototype, {
   // Will contain the actor's ID
   actorID: null,
@@ -1165,17 +1164,17 @@ var generateRequestHandlers = function(a
 
           conn.send(response);
         };
 
         this._queueResponse(p => {
           return p
             .then(() => ret)
             .then(sendReturn)
-            .catch(this.writeError.bind(this));
+            .catch(e => this.writeError(e));
         });
       } catch (e) {
         this._queueResponse(p => {
           return p.then(() => this.writeError(e));
         });
       }
     };