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)
- Xcode 15.3 YogaKit/YGLayout.m Incompatible function pointer types passing 'YGSize (YGNodeRef, float, YGMeasureMode, float, YGMeasureMode)' HOT 5
- `react-native run-ios` tries to run on a non-existent device/simulator HOT 2
- No haptic feedback when using RefreshControl with a tintColor prop
- Uncontrolled input value clears when color is changed HOT 1
- [0.74] New app hangs on blank screen if dev server is not started HOT 3
- `selectOnFocus` does not work with `autoFocus` HOT 2
- Android Native Module: Unresolved reference: PackageList HOT 2
- [0.73.6] HOT 2
- γiOSγThe contentOffset property is missing from TextInputView's onScroll callback HOT 4
- Animated.Event not working attached to onLayout with useNativeDriver enabled HOT 2
- [iOS][Information] App store submissions will require a privacy manifest and signature for hermes HOT 3
- Cookies not being sent to webview for iOS after React Native Upgrade HOT 4
- [0.74] Cannot access Dev Menu on Android (RNTester) HOT 4
- TextInput contextMenuHidden does not hide autofill HOT 1
- Showing Recent Messages Command PhaseScriptExecution failed with a nonzero exit code HOT 3
- Unknown unicode characters in Image source broken on iOS in New Architecture HOT 1
- TouchableWithoutFeedback crashes when SVG component is a direct child of it HOT 2
- FBReactNativeSpec build commands failed with RN 0.71.4 / Xcode 15.3 / M2 HOT 6
- error `fsevents` unavailable (this watcher can only be used on Darwin) HOT 2
- `@synthesize bridge = _bridge` not working with bridgeless mode and TurboModule
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.