mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Split loadApplicationScript into initializeRuntime and loadBundle (#27844)
Summary: This is the first of three PRs related to enabling multi-bundle support in React Native. More details, motivation and reasoning behind it can be found in RFC [here](https://github.com/react-native-community/discussions-and-proposals/issues/152). Logic responsible for installing globals was pulled out from `loadApplicationScript` to `initializeRuntime` since it should be ran only once, what was left was renamed to `loadBundle`. It's based on dratwas work from [here](https://github.com/callstack/react-native/tree/feat/multibundle/split-load-application), but applied to current `master` to avoid rebasing 3-months old branch and issues that come with that. ## Changelog [Internal] [Changed] - split `loadApplicationScript` into `initializeRuntime` and `loadBundle` to enable multi-bundle support in the future Pull Request resolved: https://github.com/facebook/react-native/pull/27844 Test Plan: Initialized new RN app with CLI, set RN to build from source and verified the still app builds and runs OK using code from this branch. Reviewed By: rickhanlonii Differential Revision: D19888605 Pulled By: ejanzer fbshipit-source-id: 24ace48ffe8978796591fe7c6cf53a61b127cce6
This commit is contained in:
committed by
Facebook GitHub Bot
parent
eab7fc008f
commit
6f627f684b
@@ -38,7 +38,7 @@ public interface JavaJSExecutor {
|
||||
* @param sourceURL url or file location from which script content was loaded
|
||||
*/
|
||||
@DoNotStrip
|
||||
void loadApplicationScript(String sourceURL) throws ProxyExecutorException;
|
||||
void loadBundle(String sourceURL) throws ProxyExecutorException;
|
||||
|
||||
/**
|
||||
* Execute javascript method within js context
|
||||
|
||||
+1
-1
@@ -81,7 +81,7 @@ public class JSDebuggerWebSocketClient extends WebSocketListener {
|
||||
}
|
||||
}
|
||||
|
||||
public void loadApplicationScript(
|
||||
public void loadBundle(
|
||||
String sourceURL, HashMap<String, String> injectedObjects, JSDebuggerCallback callback) {
|
||||
int requestID = mRequestID.getAndIncrement();
|
||||
mCallbacks.put(requestID, callback);
|
||||
|
||||
+3
-4
@@ -153,10 +153,9 @@ public class WebsocketJavaScriptExecutor implements JavaJSExecutor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadApplicationScript(String sourceURL) throws JavaJSExecutor.ProxyExecutorException {
|
||||
public void loadBundle(String sourceURL) throws JavaJSExecutor.ProxyExecutorException {
|
||||
JSExecutorCallbackFuture callback = new JSExecutorCallbackFuture();
|
||||
Assertions.assertNotNull(mWebSocketClient)
|
||||
.loadApplicationScript(sourceURL, mInjectedObjects, callback);
|
||||
Assertions.assertNotNull(mWebSocketClient).loadBundle(sourceURL, mInjectedObjects, callback);
|
||||
try {
|
||||
callback.get();
|
||||
} catch (Throwable cause) {
|
||||
@@ -178,7 +177,7 @@ public class WebsocketJavaScriptExecutor implements JavaJSExecutor {
|
||||
|
||||
@Override
|
||||
public void setGlobalVariable(String propertyName, String jsonEncodedValue) {
|
||||
// Store and use in the next loadApplicationScript() call.
|
||||
// Store and use in the next loadBundle() call.
|
||||
mInjectedObjects.put(propertyName, jsonEncodedValue);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user