mirror of
https://github.com/status-im/react-native.git
synced 2025-01-13 11:05:21 +00:00
Way to register RCT_MODULE in Plugin2.0 instead of +load
Summary: [RFC] WIP: Way to register RCT_MODULE in Plugin2.0 instead of +load This seemed like the simplest way to do this to register in the existing didNotFindModule callback so that we don't have to touch any opensource code. NOTE: The new version of this fixes the problems with dylibs, but not the -ObjC flag removal. This seems like the right call to avoid users having to implement c-functions to return their classes; instead we used objc_getClass. Reviewed By: dshahidehpour Differential Revision: D9112719 fbshipit-source-id: cf8df97d7c443cafa0e06a1e61bdf2612944ed87
This commit is contained in:
parent
c5297c75cb
commit
5c160e5ded
@ -21,6 +21,8 @@ RCT_EXTERN __attribute__((weak)) void RCTFBQuickPerformanceLoggerConfigureHooks(
|
||||
RCT_EXTERN void RCTVerifyAllModulesExported(NSArray *extraModules);
|
||||
#endif
|
||||
|
||||
RCT_EXTERN void RCTRegisterModule(Class);
|
||||
|
||||
@interface RCTBridge ()
|
||||
|
||||
// Private designated initializer
|
||||
|
@ -73,6 +73,16 @@ RCT_EXTERN void RCTRegisterModule(Class); \
|
||||
+ (NSString *)moduleName { return @#js_name; } \
|
||||
+ (void)load { RCTRegisterModule(self); }
|
||||
|
||||
/**
|
||||
* To improve startup performance users may want to generate their module lists
|
||||
* at build time and hook the delegate to merge with the runtime list. This
|
||||
* macro takes the place of the above for those cases by omitting the +load
|
||||
* generation.
|
||||
*
|
||||
*/
|
||||
#define RCT_EXPORT_PRE_REGISTERED_MODULE(js_name) \
|
||||
+ (NSString *)moduleName { return @#js_name; }
|
||||
|
||||
// Implemented by RCT_EXPORT_MODULE
|
||||
+ (NSString *)moduleName;
|
||||
|
||||
|
@ -650,8 +650,8 @@ struct RCTInstanceCallback : public InstanceCallback {
|
||||
// Set up moduleData for automatically-exported modules
|
||||
NSArray<RCTModuleData *> *moduleDataById = [self registerModulesForClasses:modules];
|
||||
|
||||
#ifdef RCT_DEBUG
|
||||
if (lazilyDiscovered) {
|
||||
#ifdef RCT_DEBUG
|
||||
// Lazily discovered modules do not require instantiation here,
|
||||
// as they are not allowed to have pre-instantiated instance
|
||||
// and must not require the main queue.
|
||||
@ -659,10 +659,8 @@ struct RCTInstanceCallback : public InstanceCallback {
|
||||
RCTAssert(!(moduleData.requiresMainQueueSetup || moduleData.hasInstance),
|
||||
@"Module \'%@\' requires initialization on the Main Queue or has pre-instantiated, which is not supported for the lazily discovered modules.", moduleData.name);
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
} else {
|
||||
RCT_PROFILE_BEGIN_EVENT(RCTProfileTagAlways,
|
||||
@"-[RCTCxxBridge initModulesWithDispatchGroup:] moduleData.hasInstance", nil);
|
||||
// Dispatch module init onto main thread for those modules that require it
|
||||
|
Loading…
x
Reference in New Issue
Block a user