Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent removing ReactNativeDevBundle in LiveReload #1332

Conversation

alexandergoncharov-zz
Copy link
Contributor

Fix for #1272
Prevent removing ReactNativeDevBundle.js file in case if LiveReload mode is enabled.
In other cases all behaviour is same.

public void clearDebugCacheIfNeeded(ReactInstanceManager instanceManager) {
boolean isLiveReloadEnabled = false;

if(instanceManager != null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: space missing


if(instanceManager != null) {
DevSupportManager devSupportManager = instanceManager.getDevSupportManager();
if(devSupportManager != null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: space missing

@@ -118,7 +118,12 @@ private void setJSBundle(ReactInstanceManager instanceManager, String latestJSBu

private void loadBundle() {
clearLifecycleEventListener();
mCodePush.clearDebugCacheIfNeeded();
try {
mCodePush.clearDebugCacheIfNeeded(resolveInstanceManager());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we reuse final ReactInstanceManager instanceManager = resolveInstanceManager(); variable from line 125 (from below) in clearDebugCacheIfNeeded to avoid unnecessary using reflection twice and additional try-catch block?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, we can, but we have some cases when resolveInstanceManager() has errors. In this case we should use clearDebugCacheIfNeeded with null argument. I think that adding this logic into next try-catch block is unnecessary as it make it more difficult for understanding.
Could you please share your thoughts about it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No worries, I believe current solution fits well. The only thing that I'd probably add is a comment with e.g. reference to the issue or some explanation of the intent because it could be not evident why do we need this logic at all.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, good suggestion. Thanks. I added comments.

@alexandergoncharov-zz alexandergoncharov-zz merged commit 09883dd into master Jul 9, 2018
@alexandergoncharov-zz alexandergoncharov-zz deleted the Goncharov/fix_issue_with_update_during_liveReload branch September 14, 2018 14:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants