mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
4e70376dc7
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/34514 Changelog: [Internal][iOS] Modularlize RCTBridgeModule.h 3/n - Move RCTTurboModuleRegistry.h to its own file in ReactInternal target # Why clean up RCTBridgeModule.h? Clean up one unnecessary import of RCTBridgeModule.h. RCTBridgeModule includes a lot of header files, and this header is imported everywhere. The ultimate goal is that files (especially React Native infra files) should only import only what they need and not import the entirety of RCTBridgeModule.h whenever possible. This way, certain headers that are Bridge-only can be compiled out of the new architecture with a flag. Reviewed By: RSNara Differential Revision: D38971168 fbshipit-source-id: 3b1b23d422f965a5a14bc4178d32b844906f2c8b
51 lines
1.3 KiB
Objective-C
51 lines
1.3 KiB
Objective-C
/*
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
#import "RCTBridge.h"
|
|
#import "RCTTurboModuleRegistry.h"
|
|
|
|
@class RCTBridgeModule;
|
|
|
|
@implementation RCTModuleRegistry {
|
|
__weak id<RCTTurboModuleRegistry> _turboModuleRegistry;
|
|
__weak RCTBridge *_bridge;
|
|
}
|
|
|
|
- (void)setBridge:(RCTBridge *)bridge
|
|
{
|
|
_bridge = bridge;
|
|
}
|
|
|
|
- (void)setTurboModuleRegistry:(id<RCTTurboModuleRegistry>)turboModuleRegistry
|
|
{
|
|
_turboModuleRegistry = turboModuleRegistry;
|
|
}
|
|
|
|
- (id)moduleForName:(const char *)moduleName
|
|
{
|
|
return [self moduleForName:moduleName lazilyLoadIfNecessary:YES];
|
|
}
|
|
|
|
- (id)moduleForName:(const char *)moduleName lazilyLoadIfNecessary:(BOOL)lazilyLoad
|
|
{
|
|
id<RCTBridgeModule> module = nil;
|
|
|
|
RCTBridge *bridge = _bridge;
|
|
if (bridge) {
|
|
module = [bridge moduleForName:[NSString stringWithUTF8String:moduleName] lazilyLoadIfNecessary:lazilyLoad];
|
|
}
|
|
|
|
id<RCTTurboModuleRegistry> turboModuleRegistry = _turboModuleRegistry;
|
|
if (module == nil && turboModuleRegistry && (lazilyLoad || [turboModuleRegistry moduleIsInitialized:moduleName])) {
|
|
module = [turboModuleRegistry moduleForName:moduleName];
|
|
}
|
|
|
|
return module;
|
|
}
|
|
|
|
@end
|