Skip to content

Commit

Permalink
Assure the Inspector socket runs through the lifecycle of ReactNative
Browse files Browse the repository at this point in the history
Reviewed By: AaaChiuuu

Differential Revision: D5538894

fbshipit-source-id: f48d7a1df344bd3a16f5c170b0955b7d2ef35913
  • Loading branch information
pakoito authored and facebook-github-bot committed Aug 3, 2017
1 parent 6a31284 commit 36c6943
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,9 @@ public static ReactInstanceManagerBuilder builder() {

// Instantiate ReactChoreographer in UI thread.
ReactChoreographer.initialize();
if (mUseDeveloperSupport) {
mDevSupportManager.startInspector();
}
}

public DevSupportManager getDevSupportManager() {
Expand Down Expand Up @@ -586,6 +589,7 @@ public void destroy() {

if (mUseDeveloperSupport) {
mDevSupportManager.setDevSupportEnabled(false);
mDevSupportManager.stopInspector();
}

moveToBeforeCreateLifecycleState();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -885,6 +885,18 @@ public void run() {
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) {
Expand Down Expand Up @@ -914,7 +926,6 @@ private void reload() {
}

mDevServerHelper.openPackagerConnection(this.getClass().getSimpleName(), this);
mDevServerHelper.openInspectorConnection();
if (mDevSettings.isReloadOnJSChangeEnabled()) {
mDevServerHelper.startPollingOnChangeEndpoint(
new DevServerHelper.OnServerContentChangeListener() {
Expand Down Expand Up @@ -956,9 +967,7 @@ public void onServerContentChanged() {

// hide loading view
mDevLoadingViewController.hide();

mDevServerHelper.closePackagerConnection();
mDevServerHelper.closeInspectorConnection();
mDevServerHelper.stopPollingOnChangeEndpoint();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,16 @@ public void setDevSupportEnabled(boolean isDevSupportEnabled) {

}

@Override
public void startInspector() {

}

@Override
public void stopInspector() {

}

@Override
public boolean getDevSupportEnabled() {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 36c6943

Please sign in to comment.