-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Prevent removing ReactNativeDevBundle in LiveReload #1332
Conversation
public void clearDebugCacheIfNeeded(ReactInstanceManager instanceManager) { | ||
boolean isLiveReloadEnabled = false; | ||
|
||
if(instanceManager != null) { |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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()); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
Fix for #1272
Prevent removing
ReactNativeDevBundle.js
file in case if LiveReload mode is enabled.In other cases all behaviour is same.