Make sure that TimingModule 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: D26859160

fbshipit-source-id: ce84deafd1f20d1680d333d1a176b0493623a4ee
This commit is contained in:
Joshua Gross
2021-03-05 18:42:37 -08:00
committed by Facebook GitHub Bot
parent c2e44103b9
commit 77a23bdf0f
@@ -130,10 +130,13 @@ public final class TimingModule extends NativeTimingSpec
@Override
public void onCatalystInstanceDestroy() {
ReactApplicationContext reactApplicationContext = getReactApplicationContext();
HeadlessJsTaskContext headlessJsTaskContext =
HeadlessJsTaskContext.getInstance(getReactApplicationContext());
HeadlessJsTaskContext.getInstance(reactApplicationContext);
headlessJsTaskContext.removeTaskEventListener(this);
mJavaTimerManager.onInstanceDestroy();
reactApplicationContext.removeLifecycleEventListener(this);
}
@VisibleForTesting