mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
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:
committed by
Facebook GitHub Bot
parent
d477f80113
commit
18c8417290
@@ -61,16 +61,18 @@ public abstract class BaseJavaModule implements NativeModule {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCatalystInstanceDestroy() {
|
||||
// do nothing
|
||||
}
|
||||
public void onCatalystInstanceDestroy() {}
|
||||
|
||||
public boolean hasConstants() {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Cleanup Logic for TurboModules
|
||||
/**
|
||||
* The CatalystInstance is going away with Venice. Therefore, the TurboModule infra introduces the
|
||||
* invalidate() method to allow NativeModules to clean up after themselves.
|
||||
*/
|
||||
@Override
|
||||
public void invalidate() {
|
||||
// Do nothing
|
||||
onCatalystInstanceDestroy();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user