Comments (3)
I think it's a very clever idea and I like reducing RCTJavaScriptExecutor
protocol. However, the code in the bundle has to define a global require
function that will be used by ObjC to invoke JS methods. Also there are benefits for the existing model, for example Chrome debugger integration (not in the oss repo yet) that runs the JS code in a Chrome page. The app bundle in this case is loaded via <script>
tag instead of being passed via websockets.
from react-native.
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 require
function from Obj-C is simple as well:
JSValue *exports = [reactGlobal[@"require"] callWithArguments:@[@"moduleName"]];
[exports invokeMethod:@"doSomething" withArguments:@[...]];
So in the end, RCTJavaScriptExecutor
has a smaller API and ReactKit is better encapsulated by reducing pollution of the global scope (some functions like setTimeout need another approach though).
For the Chrome debugger extension, it might be possible to keep using the real global object with the help of the packager by serving (function(global) { /* ... */ })(window);
.
from react-native.
Closing for now since it doesn't sound like this is blocking anything.
from react-native.
Related Issues (20)
- `fontVariant` doesn't work on iOS when using the new architecture
- UI problem with iOS floating keyboard in iPad. HOT 6
- TouchableWithoutFeedback does not support style HOT 1
- Cannot find EventEmitter for receivedTouches EventName[topTouchMove, topTouchEnd] on native library HOT 5
- RCTNativeAnimatedNodesManager.mm props is not a node HOT 1
- Unexpected scroll behaviors when using FlatList HOT 7
- When I integration react native with Existing Android Apps,I got a autolinking question. HOT 2
- Symbol not found: (_JSGlobalContextSetInspectable) HOT 2
- The directory ****/ios contains 2 projects HOT 3
- textInput props textAlign will cause long text to be cut off after the hyphen when out of focus and focus again
- close the first modal with animation, then open the second modal immediately, the second modal can't be showed HOT 2
- UI updates made from layout effect are flushed in separate UI transaction HOT 4
- Blob constructor is not spec compliant HOT 1
- [!] CocoaPods could not find compatible versions for pod "React-RCTAnimation": In Podfile: React-RCTAnimation (from `../node_modules/react-native/Libraries/NativeAnimation`) HOT 3
- Build error in 0.73.6 HOT 3
- Fatal error "available height is undefined" when editing textinput the app closes HOT 3
- Inverted Flatlist not working when scrolled HOT 5
- `TextInput` cursor lags behind text when component is controlled if Auto-Correction and Predictive Text are enabled HOT 3
- RNSVG same register view HOT 4
- Firestore encountered gRPC-C++ error while upgrading Firebase module to 19.2(iOS) HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native.