Add "setJsBundlesDirectory" method to CatalystInstanceImpl

Differential Revision: D6042493

fbshipit-source-id: 950c6d6bdc2e0b62b14c9bcfc86233159a002c67
This commit is contained in:
Alex Dvornikov
2017-11-01 06:33:37 -07:00
committed by Facebook Github Bot
parent 21917ab7bf
commit b5651d945c
8 changed files with 42 additions and 24 deletions

View File

@@ -210,6 +210,10 @@ public class CatalystInstanceImpl implements CatalystInstance {
jniSetSourceURL(remoteURL);
}
/* package */ void setJsBundlesDirectory(String directoryPath) {
jniSetJsBundlesDirectory(directoryPath);
}
/* package */ void loadScriptFromAssets(AssetManager assetManager, String assetURL, boolean loadSynchronously) {
mSourceURL = assetURL;
jniLoadScriptFromAssets(assetManager, assetURL, loadSynchronously);
@@ -221,6 +225,7 @@ public class CatalystInstanceImpl implements CatalystInstance {
}
private native void jniSetSourceURL(String sourceURL);
private native void jniSetJsBundlesDirectory(String directoryPath);
private native void jniLoadScriptFromAssets(AssetManager assetManager, String assetURL, boolean loadSynchronously);
private native void jniLoadScriptFromFile(String fileName, String sourceURL, boolean loadSynchronously);

View File

@@ -10,7 +10,6 @@
package com.facebook.react.bridge;
import android.content.Context;
import com.facebook.react.common.DebugServerException;
/**
@@ -98,7 +97,20 @@ public abstract class JSBundleLoader {
}
/**
* Loads the script, returning the URL of the source it loaded.
* This loader is used to wrap other loaders and set js bundles directory before executing
* application script.
*/
public static JSBundleLoader createSplitBundlesLoader(
final String jsBundlesDirectory, final JSBundleLoader delegate) {
return new JSBundleLoader() {
@Override
public String loadScript(CatalystInstanceImpl instance) {
instance.setJsBundlesDirectory(jsBundlesDirectory);
return delegate.loadScript(instance);
}
};
}
/** Loads the script, returning the URL of the source it loaded. */
public abstract String loadScript(CatalystInstanceImpl instance);
}