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:30:17 -08:00
committed by Facebook GitHub Bot
parent d477f80113
commit 18c8417290
5 changed files with 21 additions and 10 deletions
@@ -107,7 +107,7 @@ public class ModuleHolder {
public synchronized void destroy() {
if (mModule != null) {
mModule.onCatalystInstanceDestroy();
mModule.invalidate();
}
}