Update ModuleRegistry if there're new modules registered

Reviewed By: fkgozali

Differential Revision: D7638394

fbshipit-source-id: c1690da7977f0335bc661df5f19dc9f473150d41
This commit is contained in:
Dmitry Zakharov 2018-04-17 07:53:19 -07:00 committed by Facebook Github Bot
parent d2a1461d26
commit b5f90ed497

View File

@ -305,7 +305,7 @@ struct RCTInstanceCallback : public InstanceCallback {
[self registerExtraModules]; [self registerExtraModules];
// Initialize all native modules that cannot be loaded lazily // Initialize all native modules that cannot be loaded lazily
[self _initModules:RCTGetModuleClasses() withDispatchGroup:prepareBridge lazilyDiscovered:NO]; (void)[self _initializeModules:RCTGetModuleClasses() withDispatchGroup:prepareBridge lazilyDiscovered:NO];
[_performanceLogger markStopForTag:RCTPLNativeModuleInit]; [_performanceLogger markStopForTag:RCTPLNativeModuleInit];
@ -635,7 +635,7 @@ struct RCTInstanceCallback : public InstanceCallback {
} }
} }
- (void)_initModules:(NSArray<id<RCTBridgeModule>> *)modules - (NSArray<RCTModuleData *> *)_initializeModules:(NSArray<id<RCTBridgeModule>> *)modules
withDispatchGroup:(dispatch_group_t)dispatchGroup withDispatchGroup:(dispatch_group_t)dispatchGroup
lazilyDiscovered:(BOOL)lazilyDiscovered lazilyDiscovered:(BOOL)lazilyDiscovered
{ {
@ -688,11 +688,15 @@ struct RCTInstanceCallback : public InstanceCallback {
RCTProfileHookModules(self); RCTProfileHookModules(self);
} }
#endif #endif
return moduleDataById;
} }
- (void)registerAdditionalModuleClasses:(NSArray<Class> *)modules - (void)registerAdditionalModuleClasses:(NSArray<Class> *)modules
{ {
[self _initModules:modules withDispatchGroup:NULL lazilyDiscovered:YES]; NSArray<RCTModuleData *> *newModules = [self _initializeModules:modules withDispatchGroup:NULL lazilyDiscovered:YES];
if (_reactInstance) {
_reactInstance->getModuleRegistry().registerModules(createNativeModules(newModules, self, _reactInstance));
}
} }
- (void)_prepareModulesWithDispatchGroup:(dispatch_group_t)dispatchGroup - (void)_prepareModulesWithDispatchGroup:(dispatch_group_t)dispatchGroup