Assure the Inspector socket runs through the lifecycle of ReactNative

Reviewed By: AaaChiuuu

Differential Revision: D5538894

fbshipit-source-id: f48d7a1df344bd3a16f5c170b0955b7d2ef35913
This commit is contained in:
Paco Estevez Garcia 2017-08-02 17:28:48 -07:00 committed by Facebook Github Bot
parent 6a3128457f
commit 36c694364f
4 changed files with 28 additions and 3 deletions

View File

@ -280,6 +280,9 @@ public class ReactInstanceManager {
// Instantiate ReactChoreographer in UI thread.
ReactChoreographer.initialize();
if (mUseDeveloperSupport) {
mDevSupportManager.startInspector();
}
}
public DevSupportManager getDevSupportManager() {
@ -586,6 +589,7 @@ public class ReactInstanceManager {
if (mUseDeveloperSupport) {
mDevSupportManager.setDevSupportEnabled(false);
mDevSupportManager.stopInspector();
}
moveToBeforeCreateLifecycleState();

View File

@ -885,6 +885,18 @@ public class DevSupportManagerImpl implements
bundleURL);
}
@Override
public void startInspector() {
if (mIsDevSupportEnabled) {
mDevServerHelper.openInspectorConnection();
}
}
@Override
public void stopInspector() {
mDevServerHelper.closeInspectorConnection();
}
private void reload() {
// reload settings, show/hide debug overlay if required & start/stop shake detector
if (mIsDevSupportEnabled) {
@ -914,7 +926,6 @@ public class DevSupportManagerImpl implements
}
mDevServerHelper.openPackagerConnection(this.getClass().getSimpleName(), this);
mDevServerHelper.openInspectorConnection();
if (mDevSettings.isReloadOnJSChangeEnabled()) {
mDevServerHelper.startPollingOnChangeEndpoint(
new DevServerHelper.OnServerContentChangeListener() {
@ -956,9 +967,7 @@ public class DevSupportManagerImpl implements
// hide loading view
mDevLoadingViewController.hide();
mDevServerHelper.closePackagerConnection();
mDevServerHelper.closeInspectorConnection();
mDevServerHelper.stopPollingOnChangeEndpoint();
}
}

View File

@ -69,6 +69,16 @@ public class DisabledDevSupportManager implements DevSupportManager {
}
@Override
public void startInspector() {
}
@Override
public void stopInspector() {
}
@Override
public boolean getDevSupportEnabled() {
return false;

View File

@ -32,6 +32,8 @@ public interface DevSupportManager extends NativeModuleCallExceptionHandler {
void hideRedboxDialog();
void showDevOptionsDialog();
void setDevSupportEnabled(boolean isDevSupportEnabled);
void startInspector();
void stopInspector();
boolean getDevSupportEnabled();
DeveloperSettings getDevSettings();
void onNewReactContextCreated(ReactContext reactContext);