mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Make package location customizable in dev mode
Summary: @public With this, you can determine the packager location at run time before we even try to load the bundle. Changelog: [Android] [Added] - Packager location can be determined at run time Reviewed By: makovkastar Differential Revision: D18940087 fbshipit-source-id: fac99f28e119a4e7a2961b5504cfe7d2d409e8f7
This commit is contained in:
committed by
Facebook Github Bot
parent
fa78a96739
commit
3714f3648a
+19
-2
@@ -140,6 +140,7 @@ public class DevSupportManagerImpl
|
||||
private @Nullable ErrorType mLastErrorType;
|
||||
private @Nullable DevBundleDownloadListener mBundleDownloadListener;
|
||||
private @Nullable List<ErrorCustomizer> mErrorCustomizers;
|
||||
private @Nullable PackagerLocationCustomizer mPackagerLocationCustomizer;
|
||||
|
||||
private InspectorPackagerConnection.BundleStatus mBundleStatus;
|
||||
|
||||
@@ -877,8 +878,19 @@ public class DevSupportManagerImpl
|
||||
}
|
||||
|
||||
@Override
|
||||
public void isPackagerRunning(PackagerStatusCallback callback) {
|
||||
mDevServerHelper.isPackagerRunning(callback);
|
||||
public void isPackagerRunning(final PackagerStatusCallback callback) {
|
||||
Runnable checkPackagerRunning =
|
||||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mDevServerHelper.isPackagerRunning(callback);
|
||||
}
|
||||
};
|
||||
if (mPackagerLocationCustomizer != null) {
|
||||
mPackagerLocationCustomizer.run(checkPackagerRunning);
|
||||
} else {
|
||||
checkPackagerRunning.run();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1240,4 +1252,9 @@ public class DevSupportManagerImpl
|
||||
private static String getReloadAppAction(Context context) {
|
||||
return context.getPackageName() + RELOAD_APP_ACTION_SUFFIX;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPackagerLocationCustomizer(PackagerLocationCustomizer packagerLocationCustomizer) {
|
||||
mPackagerLocationCustomizer = packagerLocationCustomizer;
|
||||
}
|
||||
}
|
||||
|
||||
+5
-1
@@ -130,7 +130,7 @@ public class DisabledDevSupportManager implements DevSupportManager {
|
||||
public void reloadJSFromServer(String bundleURL) {}
|
||||
|
||||
@Override
|
||||
public void isPackagerRunning(PackagerStatusCallback callback) {}
|
||||
public void isPackagerRunning(final PackagerStatusCallback callback) {}
|
||||
|
||||
@Override
|
||||
public @Nullable File downloadBundleResourceFromUrlSync(
|
||||
@@ -151,6 +151,10 @@ public class DisabledDevSupportManager implements DevSupportManager {
|
||||
@Override
|
||||
public void registerErrorCustomizer(ErrorCustomizer errorCustomizer) {}
|
||||
|
||||
@Override
|
||||
public void setPackagerLocationCustomizer(
|
||||
PackagerLocationCustomizer packagerLocationCustomizer) {}
|
||||
|
||||
@Override
|
||||
public void handleException(Exception e) {
|
||||
mDefaultNativeModuleCallExceptionHandler.handleException(e);
|
||||
|
||||
+11
@@ -89,4 +89,15 @@ public interface DevSupportManager extends NativeModuleCallExceptionHandler {
|
||||
StackFrame[] getLastErrorStack();
|
||||
|
||||
void registerErrorCustomizer(ErrorCustomizer errorCustomizer);
|
||||
|
||||
/**
|
||||
* The PackagerLocationCustomizer allows you to have a dynamic packager location that is
|
||||
* determined right before loading the packager. Your customizer must call |callback|, as loading
|
||||
* will be blocked waiting for it to resolve.
|
||||
*/
|
||||
public interface PackagerLocationCustomizer {
|
||||
void run(Runnable callback);
|
||||
}
|
||||
|
||||
void setPackagerLocationCustomizer(PackagerLocationCustomizer packagerLocationCustomizer);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user