mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-02-10 22:45:24 +08:00
Allow developers to load JavaScript bundle from any source.
Summary: This patch adds two pieces of functionality:
- Exposes `JSBundleLoader` to allow a developer to load JavaScript bundles as they choose.
- Adds `ReactBridge.loadScripFromFile` method which loads a JavaScript bundle from an arbitrary file path.
Example usage:
```
JSBundleLoader jsBundleLoader = new JSBundleLoader() {
Override
public void loadScript(ReactBridge reactBridge) {
reactBridge.loadScriptFromFile("/sdcard/Download/index.android.bundle");
}
};
mReactInstanceManager = ReactInstanceManager.builder()
.setApplication(getApplication())
.setJSBundleLoader(jsBundleLoader)
.setJSMainModuleName("") /* necessary due to TODO(6803830) */
.addPackage(new MainReactPackage())
.setInitialLifecycleState(LifecycleState.RESUMED)
.build();
```
cc ide
Closes https://github.com/facebook/react-native/pull/3189
Reviewed By: svcscm
Differential Revision: D2535819
Pulled By: mkonicek
fb-gh-sync-id: f319299dbe29bab3b7e91f94249c14b270d9fec3
This commit is contained in:
committed by
facebook-github-bot-7
parent
b59f250214
commit
3a743ef228
@@ -65,7 +65,7 @@ public class ReactBridge extends Countable {
|
||||
* All native functions are not thread safe and appropriate queues should be used
|
||||
*/
|
||||
public native void loadScriptFromAssets(AssetManager assetManager, String assetName);
|
||||
public native void loadScriptFromNetworkCached(String sourceURL, @Nullable String tempFileName);
|
||||
public native void loadScriptFromFile(@Nullable String fileName, @Nullable String sourceURL);
|
||||
public native void callFunction(int moduleId, int methodId, NativeArray arguments);
|
||||
public native void invokeCallback(int callbackID, NativeArray arguments);
|
||||
public native void setGlobalVariable(String propertyName, String jsonEncodedArgument);
|
||||
|
||||
Reference in New Issue
Block a user