mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Make sure that FrescoModule is subscribed to LifecycleEventListener events, and unsubscribes in onCatalystInstanceDestroy
Summary: If modules are *not* eagerly init'd and expect lifecycle events, make sure (1) onHostResume is called immediately it it's currently active and (2) that listeners are removed in onCatalystInstanceDestroy. Changelog: [Internal] Reviewed By: mdvacca Differential Revision: D26859161 fbshipit-source-id: 654c055c53c0e420c6d9f2b0135055aec34269c9
This commit is contained in:
committed by
Facebook GitHub Bot
parent
4f38973b06
commit
47779de424
@@ -105,7 +105,7 @@ public class FrescoModule extends ReactContextBaseJavaModule
|
||||
@Override
|
||||
public void initialize() {
|
||||
super.initialize();
|
||||
getReactApplicationContext().addLifecycleEventListener(this);
|
||||
getReactApplicationContext().addLifecycleEventListenerAndCheckState(this);
|
||||
if (!hasBeenInitialized()) {
|
||||
if (mConfig == null) {
|
||||
mConfig = getDefaultConfig(getReactApplicationContext());
|
||||
@@ -194,4 +194,14 @@ public class FrescoModule extends ReactContextBaseJavaModule
|
||||
}
|
||||
return mImagePipeline;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCatalystInstanceDestroy() {
|
||||
super.onCatalystInstanceDestroy();
|
||||
|
||||
ReactApplicationContext applicationContext = getReactApplicationContextIfActiveOrWarn();
|
||||
if (applicationContext != null) {
|
||||
applicationContext.removeLifecycleEventListener(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user