Skip to content

Commit

Permalink
make getModuleClassFromName: required (#36968)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #36968

Changelog: [iOS][Breaking]

we should be using `optional` never. this will be a breaking change if you have any class that conform to `RCTTurboModuleManagerDelegate`

#saynotoruntimechecks

Reviewed By: cipolleschi

Differential Revision: D45022003

fbshipit-source-id: d1b3cf72bae82070704f20de4558949189da462a
  • Loading branch information
philIip authored and facebook-github-bot committed Apr 20, 2023
1 parent fce5aa7 commit fbf196d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ RCT_EXTERN void RCTTurboModuleSetBindingMode(facebook::react::TurboModuleBinding

@protocol RCTTurboModuleManagerDelegate <NSObject>

@optional

/**
* Given a module name, return its actual class. If not provided, basic ObjC class lookup is performed.
* Given a module name, return its actual class. If nil is returned, basic ObjC class lookup is performed.
*/
- (Class)getModuleClassFromName:(const char *)name;

@optional

/**
* Given a module class, provide an instance for it. If not provided, default initializer is used.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -388,14 +388,11 @@ - (TurboModuleHolder *)_getOrCreateTurboModuleHolder:(const char *)moduleName
/**
* Step 2a: Resolve platform-specific class.
*/

if ([_delegate respondsToSelector:@selector(getModuleClassFromName:)]) {
if (RCTTurboModuleManagerDelegateLockingDisabled()) {
moduleClass = [_delegate getModuleClassFromName:moduleName];
} else {
std::lock_guard<std::mutex> delegateGuard(_turboModuleManagerDelegateMutex);
moduleClass = [_delegate getModuleClassFromName:moduleName];
}
if (RCTTurboModuleManagerDelegateLockingDisabled()) {
moduleClass = [_delegate getModuleClassFromName:moduleName];
} else {
std::lock_guard<std::mutex> delegateGuard(_turboModuleManagerDelegateMutex);
moduleClass = [_delegate getModuleClassFromName:moduleName];
}

if (!moduleClass) {
Expand Down

0 comments on commit fbf196d

Please sign in to comment.