diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/JSBundleLoader.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/JSBundleLoader.java index 61bc6f0181..c62b1675aa 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/bridge/JSBundleLoader.java +++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/JSBundleLoader.java @@ -8,6 +8,7 @@ package com.facebook.react.bridge; import android.content.Context; +import com.facebook.react.bridge.NativeDeltaClient; import com.facebook.react.common.DebugServerException; /** @@ -78,6 +79,28 @@ public abstract class JSBundleLoader { }; } + /** + * This loader is used to load delta bundles from the dev server. We pass each delta message to + * the loader and process it in C++. Passing it as a string leads to inefficiencies due to memory + * copies, which will have to be addressed in a follow-up. + * @param nativeDeltaClient + */ + public static JSBundleLoader createDeltaFromNetworkLoader( + final String sourceURL, + final NativeDeltaClient nativeDeltaClient) { + return new JSBundleLoader() { + @Override + public String loadScript(CatalystInstanceImpl instance) { + try { + instance.loadScriptFromDeltaBundle(sourceURL, nativeDeltaClient, false); + return sourceURL; + } catch (Exception e) { + throw DebugServerException.makeGeneric(e.getMessage(), e); + } + } + }; + } + /** * This loader is used when proxy debugging is enabled. In that case there is no point in fetching * the bundle from device as remote executor will have to do it anyway.