Skip to content

Commit

Permalink
Refactor NativeModule API
Browse files Browse the repository at this point in the history
Summary:
EZ refactor NativeModule API:
- Reorder methods
- Add default implementation for deprecated methods

changelog: [internal] internal

Reviewed By: philIip

Differential Revision: D50610164

fbshipit-source-id: dd9dbf57be2b38c1c247858b6144f7fc6ef0fd31
  • Loading branch information
mdvacca authored and Othinn committed Jan 9, 2024
1 parent f3597ab commit 1d91d27
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,25 @@ public interface NativeModule {
/** This method is called after {@link ReactApplicationContext} has been created. */
void initialize();

/** Allow NativeModule to clean up. Called before React Native instance is destroyed. */
void invalidate();

/**
* Return true if you intend to override some other native module that was registered e.g. as part
* of a different package (such as the core one). Trying to override without returning true from
* this method is considered an error and will throw an exception during initialization. By
* default all modules return false.
*/
@DeprecatedInNewArchitecture()
boolean canOverrideExistingModule();
default boolean canOverrideExistingModule() {
return false;
}

/**
* Allow NativeModule to clean up. Called before {CatalystInstance#onHostDestroy}
*
* @deprecated use {@link #invalidate()} instead.
*/
@Deprecated(since = "Use invalidate method instead", forRemoval = true)
void onCatalystInstanceDestroy();

/** Allow NativeModule to clean up. Called before React Native instance is destroyed. */
void invalidate();
default void onCatalystInstanceDestroy() {}
}

0 comments on commit 1d91d27

Please sign in to comment.