mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-30 22:12:42 +08:00
Provide sync vs async interface for bundle loading via parameter
Reviewed By: javache Differential Revision: D5104317 fbshipit-source-id: ffacb57d85c24795a3acc2faba2ff5824cc739b2
This commit is contained in:
committed by
Facebook Github Bot
parent
d59fd9e419
commit
f46eaa30cf
@@ -26,11 +26,12 @@ public abstract class JSBundleLoader {
|
||||
*/
|
||||
public static JSBundleLoader createAssetLoader(
|
||||
final Context context,
|
||||
final String assetUrl) {
|
||||
final String assetUrl,
|
||||
final boolean loadSynchronously) {
|
||||
return new JSBundleLoader() {
|
||||
@Override
|
||||
public String loadScript(CatalystInstanceImpl instance) {
|
||||
instance.loadScriptFromAssets(context.getAssets(), assetUrl);
|
||||
instance.loadScriptFromAssets(context.getAssets(), assetUrl, loadSynchronously);
|
||||
return assetUrl;
|
||||
}
|
||||
};
|
||||
@@ -41,16 +42,17 @@ public abstract class JSBundleLoader {
|
||||
* passing large strings from java to native memorory.
|
||||
*/
|
||||
public static JSBundleLoader createFileLoader(final String fileName) {
|
||||
return createFileLoader(fileName, fileName);
|
||||
return createFileLoader(fileName, fileName, false);
|
||||
}
|
||||
|
||||
public static JSBundleLoader createFileLoader(
|
||||
final String fileName,
|
||||
final String assetUrl) {
|
||||
final String assetUrl,
|
||||
final boolean loadSynchronously) {
|
||||
return new JSBundleLoader() {
|
||||
@Override
|
||||
public String loadScript(CatalystInstanceImpl instance) {
|
||||
instance.loadScriptFromFile(fileName, assetUrl);
|
||||
instance.loadScriptFromFile(fileName, assetUrl, loadSynchronously);
|
||||
return fileName;
|
||||
}
|
||||
};
|
||||
@@ -70,7 +72,7 @@ public abstract class JSBundleLoader {
|
||||
@Override
|
||||
public String loadScript(CatalystInstanceImpl instance) {
|
||||
try {
|
||||
instance.loadScriptFromFile(cachedFileLocation, sourceURL);
|
||||
instance.loadScriptFromFile(cachedFileLocation, sourceURL, false);
|
||||
return sourceURL;
|
||||
} catch (Exception e) {
|
||||
throw DebugServerException.makeGeneric(e.getMessage(), e);
|
||||
|
||||
Reference in New Issue
Block a user