mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
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:
@@ -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 => {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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__;
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user