Created
June 23, 2016 01:12
-
-
Save mactive/c17a2dca25b3711e32c713a9f0006e9b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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)); | |
} | |
} | |
}; |
Author
mactive
commented
Jun 23, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment