Skip to content

Commit d5253d3

Browse files
committed
Removing one of the listeners.
1 parent b03ae54 commit d5253d3

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

app/middlewares/debuggerAPI.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ let socket;
3333
const workerOnMessage = message => {
3434
const { data } = message;
3535

36+
if (data && data.source === 'apollo-devtools-proxy') {
37+
const message = typeof data.payload === 'string' ? { event: data.payload } : data.payload;
38+
worker.postMessage({ source: 'apollo-devtools-proxy', ...message });
39+
}
40+
3641
if (data.source === 'apollo-devtools-backend') {
3742
if (!window.__APOLLO_DEVTOOLS_SHOULD_DISPLAY_PANEL__) {
3843
window.__APOLLO_DEVTOOLS_SHOULD_DISPLAY_PANEL__ = true;
@@ -55,21 +60,13 @@ const workerOnMessage = message => {
5560
socket.send(JSON.stringify(data));
5661
};
5762

58-
const onWindowMessage = e => {
59-
if (e.data && e.data.source === 'apollo-devtools-proxy') {
60-
const message = typeof e.data.payload === 'string' ? { event: e.data.payload } : e.data.payload;
61-
worker.postMessage({ source: 'apollo-devtools-proxy', ...message });
62-
}
63-
};
64-
6563
const createJSRuntime = () => {
6664
// This worker will run the application javascript code,
6765
// making sure that it's run in an environment without a global
6866
// document, to make it consistent with the JSC executor environment.
6967
// eslint-disable-next-line
7068
worker = new Worker(`${__webpack_public_path__}RNDebuggerWorker.js`);
7169
worker.addEventListener('message', workerOnMessage);
72-
window.addEventListener('message', onWindowMessage);
7370
actions.setDebuggerWorker(worker, 'connected');
7471
};
7572

@@ -78,7 +75,6 @@ const shutdownJSRuntime = () => {
7875
scriptExecuted = false;
7976
if (worker) {
8077
worker.terminate();
81-
window.removeEventListener('messsage', onWindowMessage);
8278
setDevMenuMethods([]);
8379
}
8480
worker = null;

0 commit comments

Comments
 (0)