mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Refactor: Remove AsyncDevSupportManager.loadJSBundleFromServer
Summary: ## Rationale - AsyncDevSupportManager.loadSplitBundleFromServer() is an override of DevSupportManager.loadSplitBundleFromServer(), which is used by the bridge. However, AsyncDevSupportManager.loadJSBundleFromServer() has no bridge analogue. This is confusing: Are the methods in AsyncDevSupportManager Venice overrides for bridge related methods? It's easy to think yes, but the answer is no. - AsyncDevSupportManager.loadJSBundleFromServer() is an additional layer of indirection that provides very little value: all it does it create the JSBundleLoader, and call onReactContextCreated. However, it does so in 11 lines of very confusing code. A discussion we don't have to have now: Inheritance hierarchies are very difficult to understand and de-tangle. So, instead of using inheritance to make DevSupportManager work with Venice (via AsyncDevSupportManager), should we just refactor DevSupportManager so that it can be customized to work with Venice? Changelog: [Internal] Reviewed By: JoshuaGross, mdvacca Differential Revision: D27577591 fbshipit-source-id: b64dcd65e9a7c85b89443d860d441a0635547916
This commit is contained in:
committed by
Facebook GitHub Bot
parent
f525ec0fe5
commit
5f0bf8b2e9
@@ -43,6 +43,7 @@ import com.facebook.react.common.ReactConstants;
|
||||
import com.facebook.react.common.ShakeDetector;
|
||||
import com.facebook.react.common.futures.SimpleSettableFuture;
|
||||
import com.facebook.react.devsupport.DevServerHelper.PackagerCommandListener;
|
||||
import com.facebook.react.devsupport.interfaces.BundleLoadCallback;
|
||||
import com.facebook.react.devsupport.interfaces.DevBundleDownloadListener;
|
||||
import com.facebook.react.devsupport.interfaces.DevOptionHandler;
|
||||
import com.facebook.react.devsupport.interfaces.DevSplitBundleCallback;
|
||||
@@ -1151,11 +1152,7 @@ public abstract class DevSupportManagerBase
|
||||
});
|
||||
}
|
||||
|
||||
protected interface BundleLoadCallback {
|
||||
void onSuccess();
|
||||
}
|
||||
|
||||
protected void reloadJSFromServer(final String bundleURL, final BundleLoadCallback callback) {
|
||||
public void reloadJSFromServer(final String bundleURL, final BundleLoadCallback callback) {
|
||||
ReactMarker.logMarker(ReactMarkerConstants.DOWNLOAD_START);
|
||||
|
||||
mDevLoadingViewController.showForUrl(bundleURL);
|
||||
|
||||
+4
@@ -12,6 +12,7 @@ import androidx.annotation.Nullable;
|
||||
import com.facebook.react.bridge.DefaultNativeModuleCallExceptionHandler;
|
||||
import com.facebook.react.bridge.ReactContext;
|
||||
import com.facebook.react.bridge.ReadableArray;
|
||||
import com.facebook.react.devsupport.interfaces.BundleLoadCallback;
|
||||
import com.facebook.react.devsupport.interfaces.DevOptionHandler;
|
||||
import com.facebook.react.devsupport.interfaces.DevSplitBundleCallback;
|
||||
import com.facebook.react.devsupport.interfaces.DevSupportManager;
|
||||
@@ -131,6 +132,9 @@ public class DisabledDevSupportManager implements DevSupportManager {
|
||||
@Override
|
||||
public void reloadJSFromServer(String bundleURL) {}
|
||||
|
||||
@Override
|
||||
public void reloadJSFromServer(final String bundleURL, final BundleLoadCallback callback) {}
|
||||
|
||||
@Override
|
||||
public void loadSplitBundleFromServer(String bundlePath, DevSplitBundleCallback callback) {}
|
||||
|
||||
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
package com.facebook.react.devsupport.interfaces;
|
||||
|
||||
public interface BundleLoadCallback {
|
||||
void onSuccess();
|
||||
}
|
||||
+2
@@ -69,6 +69,8 @@ public interface DevSupportManager extends NativeModuleCallExceptionHandler {
|
||||
|
||||
void reloadJSFromServer(final String bundleURL);
|
||||
|
||||
void reloadJSFromServer(final String bundleURL, final BundleLoadCallback callback);
|
||||
|
||||
void loadSplitBundleFromServer(String bundlePath, DevSplitBundleCallback callback);
|
||||
|
||||
void isPackagerRunning(PackagerStatusCallback callback);
|
||||
|
||||
Reference in New Issue
Block a user