Deprecate NativeModule.onCatalystInstanceDestroy()

Summary:
## Rationale
The CatalystInstance is going away after we delete the bridge. So, we should migrate away from onCatalystInstanceDestroy() to something else: invalidate().

## Changes
- Introduce the NativeModule.invalidate() cleanup hook.
- Both the NativeModule and TurboModule infra now call this invalidate() method, **as opposed to** onCatalystInstanceDestroy(), to perform NativeModule cleanup.
- **Is this safe?** All our NativeModules extend BaseJavaModule. BaseJavaModule.invalidate() delegates to NativeModule.onCatalystInstanceDestroy(), so NativeModules that implement onCatalystInstanceDestroy(), but not invalidate(), still have their onCatalystInstanceDestroy() method called.

Changelog: [Android][Deprecated] - Deprecate NativeModule.onCatalystInstanceDestroy() for NativeModule.invalidate()

Reviewed By: JoshuaGross

Differential Revision: D26871001

fbshipit-source-id: e3bdfa0cf653ecbfe42791631bc6229af62f4817
This commit is contained in:
Ramanpreet Nara
2021-03-06 20:27:48 -08:00
committed by Facebook GitHub Bot
parent d477f80113
commit 18c8417290
5 changed files with 21 additions and 10 deletions
@@ -47,6 +47,13 @@ public interface NativeModule {
*/
boolean canOverrideExistingModule();
/** Called before {CatalystInstance#onHostDestroy} */
/**
* Allow NativeModule to clean up. Called before {CatalystInstance#onHostDestroy}
*
* @deprecated use {@link #invalidate()} instead.
*/
void onCatalystInstanceDestroy();
/** Allow NativeModule to clean up. Called before {CatalystInstance#onHostDestroy} */
void invalidate();
}