Bug 1468754 Part 4: Make ChangesActor fire events. r=pbro
Depends on D9050
Differential Revision:
https://phabricator.services.mozilla.com/D9176
--- 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"),
},
},
},
});