Merge pull request #239 from sompylasar/remove-agent-addbridge

Remove Agent addBridge: there can only be one bridge, add in constructor
This commit is contained in:
Dan Abramov
2019-04-28 13:38:34 +01:00
committed by GitHub
4 changed files with 6 additions and 11 deletions
+1 -2
View File
@@ -54,8 +54,7 @@ function setup(hook) {
},
});
const agent = new Agent();
agent.addBridge(bridge);
const agent = new Agent(bridge);
agent.addListener('shutdown', () => {
hook.emit('shutdown');
listeners.forEach(fn => {
+1 -2
View File
@@ -25,7 +25,6 @@ bridge.addListener('captureScreenshot', ({ commitIndex }) => {
});
});
const agent = new Agent();
agent.addBridge(bridge);
const agent = new Agent(bridge);
initBackend(window.__REACT_DEVTOOLS_GLOBAL_HOOK__, agent, window.parent);
+1 -2
View File
@@ -38,8 +38,7 @@ env.beforeEach(() => {
},
});
const agent = new Agent();
agent.addBridge(bridge);
const agent = new Agent(bridge);
const hook = global.__REACT_DEVTOOLS_GLOBAL_HOOK__;
+3 -5
View File
@@ -61,13 +61,13 @@ type PersistedSelection = {|
|};
export default class Agent extends EventEmitter {
_bridge: Bridge = ((null: any): Bridge);
_bridge: Bridge;
_isProfiling: boolean = false;
_rendererInterfaces: { [key: RendererID]: RendererInterface } = {};
_persistedSelection: PersistedSelection | null = null;
_persistedSelectionMatch: PathMatch | null = null;
constructor() {
constructor(bridge: Bridge) {
super();
if (localStorage.getItem(LOCAL_STORAGE_RELOAD_AND_PROFILE_KEY) === 'true') {
@@ -84,9 +84,7 @@ export default class Agent extends EventEmitter {
this._persistedSelection = JSON.parse(persistedSelectionString);
}
}
}
addBridge(bridge: Bridge) {
this._bridge = bridge;
bridge.addListener('captureScreenshot', this.captureScreenshot);
@@ -123,7 +121,7 @@ export default class Agent extends EventEmitter {
bridge.addListener('viewElementSource', this.viewElementSource);
if (this._isProfiling) {
this._bridge.send('profilingStatus', true);
bridge.send('profilingStatus', true);
}
}