Skip to content

Instantly share code, notes, and snippets.

@mactive
Created June 23, 2016 01:12
Show Gist options
  • Save mactive/c17a2dca25b3711e32c713a9f0006e9b to your computer and use it in GitHub Desktop.
Save mactive/c17a2dca25b3711e32c713a9f0006e9b to your computer and use it in GitHub Desktop.
// file location:
// node_modules/react-native/local-cli/server/util/debuggerWorker.js
var messageHandlers = {
'executeApplicationScript': function(message, sendReply) {
for (var key in message.inject) {
self[key] = JSON.parse(message.inject[key]);
}
importScripts(message.url);
sendReply();
}
};
onmessage = function(message) {
var object = message.data;
var sendReply = function(result) {
postMessage({replyID: object.id, result: result});
};
var handler = messageHandlers[object.method];
if (handler) {
// Special cased handlers
handler(object, sendReply);
} else {
// Other methods get called on the bridge
var returnValue = [[], [], [], [], []];
try {
if (typeof __fbBatchedBridge === 'object') {
returnValue = __fbBatchedBridge[object.method].apply(null, object.arguments);
}
} finally {
sendReply(JSON.stringify(returnValue));
}
}
};
@mactive
Copy link
Author

mactive commented Jun 23, 2016

debuggerworker

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment