mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
pass eager initialized modules directly to bridge (#36916)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/36916 Changelog: [iOS][Removed] the bridge only behavior of eager initialization of native modules was coupled with the turbomodule infra, even though it didn't need to be. this eager initialized modules is a static list, and the bridge owner which is usually app scoped, can pass this list directly to the bridge instead. Reviewed By: sammy-SC Differential Revision: D45021784 fbshipit-source-id: f033661e0722f65ae971bd7ce27f8dc7de1173ad
This commit is contained in:
committed by
Facebook GitHub Bot
parent
ee271c84c2
commit
9e5c963e2d
@@ -70,6 +70,9 @@ RCT_EXTERN void RCTRegisterModule(Class);
|
||||
*/
|
||||
@property (nonatomic, strong, readonly) RCTModuleRegistry *moduleRegistry;
|
||||
|
||||
@property (nonatomic, copy, readwrite) NSArray<NSString *> *eagerInitModuleNames_DO_NOT_USE;
|
||||
@property (nonatomic, copy, readwrite) NSArray<NSString *> *eagerInitMainQueueModuleNames_DO_NOT_USE;
|
||||
|
||||
@end
|
||||
|
||||
@interface RCTBridge (RCTCxxBridge)
|
||||
|
||||
@@ -23,7 +23,4 @@
|
||||
*/
|
||||
- (id)moduleForName:(const char *)moduleName warnOnLookupFailure:(BOOL)warnOnLookupFailure;
|
||||
- (BOOL)moduleIsInitialized:(const char *)moduleName;
|
||||
|
||||
- (NSArray<NSString *> *)eagerInitModuleNames;
|
||||
- (NSArray<NSString *> *)eagerInitMainQueueModuleNames;
|
||||
@end
|
||||
|
||||
@@ -448,11 +448,11 @@ struct RCTInstanceCallback : public InstanceCallback {
|
||||
* RCTCxxBridge If id<RCTTurboModuleRegistry> is assigned by this time, eagerly initialize all TurboModules
|
||||
*/
|
||||
if (_turboModuleRegistry && RCTTurboModuleEagerInitEnabled()) {
|
||||
for (NSString *moduleName in [_turboModuleRegistry eagerInitModuleNames]) {
|
||||
for (NSString *moduleName in [_parentBridge eagerInitModuleNames_DO_NOT_USE]) {
|
||||
[_turboModuleRegistry moduleForName:[moduleName UTF8String]];
|
||||
}
|
||||
|
||||
for (NSString *moduleName in [_turboModuleRegistry eagerInitMainQueueModuleNames]) {
|
||||
for (NSString *moduleName in [_parentBridge eagerInitMainQueueModuleNames_DO_NOT_USE]) {
|
||||
if (RCTIsMainQueue()) {
|
||||
[_turboModuleRegistry moduleForName:[moduleName UTF8String]];
|
||||
} else {
|
||||
|
||||
-2
@@ -20,8 +20,6 @@ RCT_EXTERN void RCTTurboModuleSetBindingMode(facebook::react::TurboModuleBinding
|
||||
@protocol RCTTurboModuleManagerDelegate <NSObject>
|
||||
|
||||
@optional
|
||||
- (NSArray<NSString *> *)getEagerInitModuleNames;
|
||||
- (NSArray<NSString *> *)getEagerInitMainQueueModuleNames;
|
||||
|
||||
/**
|
||||
* Given a module name, return its actual class. If not provided, basic ObjC class lookup is performed.
|
||||
|
||||
-18
@@ -775,24 +775,6 @@ static Class getFallbackClassFromName(const char *name)
|
||||
return _turboModuleHolders.find(moduleName) != _turboModuleHolders.end();
|
||||
}
|
||||
|
||||
- (NSArray<NSString *> *)eagerInitModuleNames
|
||||
{
|
||||
if ([_delegate respondsToSelector:@selector(getEagerInitModuleNames)]) {
|
||||
return [_delegate getEagerInitModuleNames];
|
||||
}
|
||||
|
||||
return @[];
|
||||
}
|
||||
|
||||
- (NSArray<NSString *> *)eagerInitMainQueueModuleNames
|
||||
{
|
||||
if ([_delegate respondsToSelector:@selector(getEagerInitMainQueueModuleNames)]) {
|
||||
return [_delegate getEagerInitMainQueueModuleNames];
|
||||
}
|
||||
|
||||
return @[];
|
||||
}
|
||||
|
||||
#pragma mark Invalidation logic
|
||||
|
||||
- (void)bridgeWillInvalidateModules:(NSNotification *)notification
|
||||
|
||||
Reference in New Issue
Block a user