mirror of
https://github.com/status-im/react-native.git
synced 2025-01-29 10:45:04 +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);
|
RCT_EXTERN void RCTVerifyAllModulesExported(NSArray *extraModules);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
RCT_EXTERN void RCTRegisterModule(Class);
|
||||||
|
|
||||||
@interface RCTBridge ()
|
@interface RCTBridge ()
|
||||||
|
|
||||||
// Private designated initializer
|
// Private designated initializer
|
||||||
|
@ -73,6 +73,16 @@ RCT_EXTERN void RCTRegisterModule(Class); \
|
|||||||
+ (NSString *)moduleName { return @#js_name; } \
|
+ (NSString *)moduleName { return @#js_name; } \
|
||||||
+ (void)load { RCTRegisterModule(self); }
|
+ (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
|
// Implemented by RCT_EXPORT_MODULE
|
||||||
+ (NSString *)moduleName;
|
+ (NSString *)moduleName;
|
||||||
|
|
||||||
|
@ -650,8 +650,8 @@ struct RCTInstanceCallback : public InstanceCallback {
|
|||||||
// Set up moduleData for automatically-exported modules
|
// Set up moduleData for automatically-exported modules
|
||||||
NSArray<RCTModuleData *> *moduleDataById = [self registerModulesForClasses:modules];
|
NSArray<RCTModuleData *> *moduleDataById = [self registerModulesForClasses:modules];
|
||||||
|
|
||||||
#ifdef RCT_DEBUG
|
|
||||||
if (lazilyDiscovered) {
|
if (lazilyDiscovered) {
|
||||||
|
#ifdef RCT_DEBUG
|
||||||
// Lazily discovered modules do not require instantiation here,
|
// Lazily discovered modules do not require instantiation here,
|
||||||
// as they are not allowed to have pre-instantiated instance
|
// as they are not allowed to have pre-instantiated instance
|
||||||
// and must not require the main queue.
|
// and must not require the main queue.
|
||||||
@ -659,10 +659,8 @@ struct RCTInstanceCallback : public InstanceCallback {
|
|||||||
RCTAssert(!(moduleData.requiresMainQueueSetup || moduleData.hasInstance),
|
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);
|
@"Module \'%@\' requires initialization on the Main Queue or has pre-instantiated, which is not supported for the lazily discovered modules.", moduleData.name);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
#endif
|
#endif
|
||||||
{
|
} else {
|
||||||
RCT_PROFILE_BEGIN_EVENT(RCTProfileTagAlways,
|
RCT_PROFILE_BEGIN_EVENT(RCTProfileTagAlways,
|
||||||
@"-[RCTCxxBridge initModulesWithDispatchGroup:] moduleData.hasInstance", nil);
|
@"-[RCTCxxBridge initModulesWithDispatchGroup:] moduleData.hasInstance", nil);
|
||||||
// Dispatch module init onto main thread for those modules that require it
|
// Dispatch module init onto main thread for those modules that require it
|
||||||
|
Loading…
x
Reference in New Issue
Block a user