Bug 1468754 Part 3: Add a TrackChangesEmitter helper object, and make ChangesActor listen to it. r=pbro

Depends on D9049

Differential Revision: https://phabricator.services.mozilla.com/D9050

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Brad Werth 2018-10-22 18:00:55 +00:00
parent 6927652361
commit 7972326743
3 changed files with 29 additions and 1 deletions

View File

@ -9,6 +9,7 @@ const protocol = require("devtools/shared/protocol");
const {getCSSLexer} = require("devtools/shared/css/lexer");
const {LongStringActor} = require("devtools/server/actors/string");
const InspectorUtils = require("InspectorUtils");
const TrackChangeEmitter = require("devtools/server/actors/utils/track-change-emitter");
// This will also add the "stylesheet" actor type for protocol.js to recognize
@ -1520,7 +1521,7 @@ var StyleRuleActor = protocol.ActorClassWithSpec(styleRuleSpec, {
return;
}
this.emit("track-change", data);
TrackChangeEmitter.trackChange(data);
},
/**

View File

@ -21,5 +21,6 @@ DevToolsModules(
'source-actor-store.js',
'stack.js',
'TabSources.js',
'track-change-emitter.js',
'walker-search.js',
)

View File

@ -0,0 +1,26 @@
/* 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 EventEmitter = require("devtools/shared/event-emitter");
/**
* A helper class that is listened to by the ChangesActor, and can be
* used to send changes to the ChangesActor.
*/
class TrackChangeEmitter {
/**
* Initialize this object.
*/
constructor() {
EventEmitter.decorate(this);
}
trackChange(change) {
this.emit("track-change", change);
}
}
module.exports = new TrackChangeEmitter();