Skip to content

Commit

Permalink
Deprecate getSurfacePresenter and getModuleRegistry in favor of t…
Browse files Browse the repository at this point in the history
…heir props

Summary:
This change align the `getSurfacePresenter` and `getModuleRegistry` to the iOS convention for which these should be computed properties with no `get` prefix in their name.

We want to land this change and to pick it in 0.74 so we can remove the `get` versions in 0.75.

## Changelog:
[iOS][Deprecated] - Deprecate `getSurfacePresenter` and `getModuleRegistry` for `surfacePresenter` and moduleRegistry` props.

Reviewed By: javache

Differential Revision: D54253805

fbshipit-source-id: e9ff7db744a73a3bd0f8ae1d87875e54ddd9a1a4
  • Loading branch information
cipolleschi authored and facebook-github-bot committed Feb 28, 2024
1 parent 57ed0fb commit c3b0a8f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ typedef std::shared_ptr<facebook::react::JSRuntimeFactory> (^RCTHostJSEngineProv

@property (nonatomic, weak, nullable) id<RCTHostRuntimeDelegate> runtimeDelegate;

@property (nonatomic, readonly) RCTSurfacePresenter *surfacePresenter;

@property (nonatomic, readonly) RCTModuleRegistry *moduleRegistry;

- (void)start;

- (void)callFunctionOnJSModule:(NSString *)moduleName method:(NSString *)method args:(NSArray *)args;
Expand All @@ -64,11 +68,11 @@ typedef std::shared_ptr<facebook::react::JSRuntimeFactory> (^RCTHostJSEngineProv

- (RCTFabricSurface *)createSurfaceWithModuleName:(NSString *)moduleName initialProperties:(NSDictionary *)properties;

- (RCTSurfacePresenter *)getSurfacePresenter;
- (RCTSurfacePresenter *)getSurfacePresenter __attribute__((deprecated("Use `surfacePresenter` property instead.")));

// Native module API

- (RCTModuleRegistry *)getModuleRegistry;
- (RCTModuleRegistry *)getModuleRegistry __attribute__((deprecated("Use `moduleRegistry` property instead.")));

@end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ - (RCTFabricSurface *)createSurfaceWithModuleName:(NSString *)moduleName
mode:(DisplayMode)displayMode
initialProperties:(NSDictionary *)properties
{
RCTFabricSurface *surface = [[RCTFabricSurface alloc] initWithSurfacePresenter:[self getSurfacePresenter]
RCTFabricSurface *surface = [[RCTFabricSurface alloc] initWithSurfacePresenter:self.surfacePresenter
moduleName:moduleName
initialProperties:properties];
surface.surfaceHandler.setDisplayMode(displayMode);
Expand All @@ -235,16 +235,28 @@ - (RCTFabricSurface *)createSurfaceWithModuleName:(NSString *)moduleName initial
return [self createSurfaceWithModuleName:moduleName mode:DisplayMode::Visible initialProperties:properties];
}

- (RCTModuleRegistry *)getModuleRegistry
- (RCTModuleRegistry *)moduleRegistry
{
return _moduleRegistry;
}

- (RCTSurfacePresenter *)getSurfacePresenter
// Deprecated
- (RCTModuleRegistry *)getModuleRegistry
{
return self.moduleRegistry;
}

- (RCTSurfacePresenter *)surfacePresenter
{
return [_instance surfacePresenter];
}

// Deprecated
- (RCTSurfacePresenter *)getSurfacePresenter
{
return self.surfacePresenter;
}

- (void)callFunctionOnJSModule:(NSString *)moduleName method:(NSString *)method args:(NSArray *)args
{
[_instance callFunctionOnJSModule:moduleName method:method args:args];
Expand Down Expand Up @@ -276,7 +288,7 @@ - (void)didReceiveReloadCommand
[_hostDelegate hostDidStart:self];

for (RCTFabricSurface *surface in [self _getAttachedSurfaces]) {
[surface resetWithSurfacePresenter:[self getSurfacePresenter]];
[surface resetWithSurfacePresenter:self.surfacePresenter];
}
}

Expand Down

0 comments on commit c3b0a8f

Please sign in to comment.