Bug 1468754 Part 4: Make ChangesActor fire events. r=pbro
☠☠ backed out by 7f6a5b37d2ca ☠ ☠
authorBrad Werth <bwerth@mozilla.com>
Mon, 22 Oct 2018 16:31:36 +0000
changeset 490771 c98ac75031113691ef2e0dcec903db85b41bcd63
parent 490770 ddd043a258e0852b4d64f1614f09dc4204231e8c
child 490772 c36e8383aa3ac580f99c69011eebca5fce6b0830
push id247
push userfmarier@mozilla.com
push dateSat, 27 Oct 2018 01:06:44 +0000
reviewerspbro
bugs1468754
milestone64.0a1
Bug 1468754 Part 4: Make ChangesActor fire events. r=pbro Depends on D9050 Differential Revision: https://phabricator.services.mozilla.com/D9176
devtools/server/actors/changes.js
devtools/shared/specs/changes.js
--- a/devtools/server/actors/changes.js
+++ b/devtools/server/actors/changes.js
@@ -51,20 +51,24 @@ const ChangesActor = protocol.ActorClass
   },
 
   allChanges: function() {
     return this.changes.slice();
   },
 
   pushChange: function(change) {
     this.changes.push(change);
+    this.emit("add-change", change);
   },
 
   popChange: function() {
-    return this.changes.pop();
+    const change = this.changes.pop();
+    this.emit("remove-change", change);
+    return change;
   },
 
   clearChanges: function() {
     this.changes.length = 0;
+    this.emit("clear-changes");
   },
 });
 
 exports.ChangesActor = ChangesActor;
--- a/devtools/shared/specs/changes.js
+++ b/devtools/shared/specs/changes.js
@@ -1,22 +1,37 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 "use strict";
 
 const {
+  Arg,
   generateActorSpec,
   RetVal,
 } = require("devtools/shared/protocol");
 
 const changesSpec = generateActorSpec({
   typeName: "changes",
 
+  events: {
+    "add-change": {
+      type: "addChange",
+      change: Arg(0, "json"),
+    },
+    "remove-change": {
+      type: "removeChange",
+      change: Arg(0, "json"),
+    },
+    "clear-changes": {
+      type: "clearChanges",
+    },
+  },
+
   methods: {
     "allChanges": {
       response: {
         changes: RetVal("array:json"),
       },
     },
   },
 });