-
Notifications
You must be signed in to change notification settings - Fork 24.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bridge] Pass __fbBatchedBridgeConfig into the bundle instead of making it global #62
Comments
I think it's a very clever idea and I like reducing |
Could the JS application engine be set up by passing in a global object? For example: (function(global) {
// Make require.js use "global", which passes it to all of the module factory functions.
// require.js also sets "global.require", "global.requireLazy", etc...
}); From the native side, the application engine is initialized like: // Create a "global" object. May need to have it act as a proxy to the real global object
// and would need to write a little more code for that.
JSValue *reactGlobal = [JSValue valueWithNewObjectInContext:context];
reactGlobal[@"__fbBatchedBridgeConfig"] = bridgeConfigDictionary;
[[context evaluateScript:bundleScriptString] callWithArguments:@[reactGlobal]]; Accessing the global JSValue *exports = [reactGlobal[@"require"] callWithArguments:@[@"moduleName"]];
[exports invokeMethod:@"doSomething" withArguments:@[...]]; So in the end, For the Chrome debugger extension, it might be possible to keep using the real global object with the help of the packager by serving |
Closing for now since it doesn't sound like this is blocking anything. |
This is to reduce globals and encourage scoping. A specific approach I have in mind is to make the bundle produce a function that takes the bridge config as an argument:
And when setting up ReactKit:
Then the global goes away and you don't need
-[RCTJavaScriptExecutor injectJSONText:asGlobalObjectNamed:callback:]
either!The text was updated successfully, but these errors were encountered: