mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Refactor reloadJSFromServer to use a callback internally
Summary: This is step 3 in creating a new DevSupportManager with a better async API for loading the JS bundle from Metro. Right now DevSupportManagerImpl calls a method on its ReactInstanceManagerDevHelper delegate when the JS bundle is done being downloaded from the server. However, I want to move to a callback-based method for bridgeless mode (similar to packager status). In this diff, I'm adding a protected method that uses a callback, and then calling that from `reloadJSFromServer` with a callback that calls the delegate, to preserve existing behavior. Changelog: [Internal] Reviewed By: mdvacca Differential Revision: D19871102 fbshipit-source-id: 2dbb6b91c5b927df86c3db42aa11e080d57ea78e
This commit is contained in:
committed by
Facebook Github Bot
parent
506e3a208e
commit
5ff9ae4a46
+23
-9
@@ -1012,6 +1012,27 @@ public abstract class DevSupportManagerBase
|
||||
}
|
||||
|
||||
public void reloadJSFromServer(final String bundleURL) {
|
||||
reloadJSFromServer(
|
||||
bundleURL,
|
||||
new BundleLoadCallback() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
UiThreadUtil.runOnUiThread(
|
||||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mReactInstanceManagerHelper.onJSBundleLoadedFromServer();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected interface BundleLoadCallback {
|
||||
void onSuccess();
|
||||
}
|
||||
|
||||
protected void reloadJSFromServer(final String bundleURL, final BundleLoadCallback callback) {
|
||||
ReactMarker.logMarker(ReactMarkerConstants.DOWNLOAD_START);
|
||||
|
||||
mDevLoadingViewController.showForUrl(bundleURL);
|
||||
@@ -1032,15 +1053,8 @@ public abstract class DevSupportManagerBase
|
||||
if (mBundleDownloadListener != null) {
|
||||
mBundleDownloadListener.onSuccess();
|
||||
}
|
||||
UiThreadUtil.runOnUiThread(
|
||||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ReactMarker.logMarker(
|
||||
ReactMarkerConstants.DOWNLOAD_END, bundleInfo.toJSONString());
|
||||
mReactInstanceManagerHelper.onJSBundleLoadedFromServer();
|
||||
}
|
||||
});
|
||||
ReactMarker.logMarker(ReactMarkerConstants.DOWNLOAD_END, bundleInfo.toJSONString());
|
||||
callback.onSuccess();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user