TM iOS: rollout strategy 1 - added RCTEnableJSINativeModule(BOOL)
Summary: To be able to test out new approach for NativeModules, introduce a simple runtime flag to enable the new system (doesn't exist yet). In addition, each module should declare a static `+ (BOOL)allowJSIBinding` in the objc class to be considered for the new approach. Doing so skips the processing of the module during bridge startup. Note: this doesn't do anything special for `- (NSArray *)extraModulesForBridge:(RCTBridge *)bridge` impl yet. Differential Revision: D9554296 fbshipit-source-id: 3508db6589e9f72367f62aa7ca15fce3d3adda72
This commit is contained in:
parent
eb225fa173
commit
6a1f48e06d
|
@ -93,6 +93,13 @@ typedef NSArray<id<RCTBridgeModule>> *(^RCTBridgeModuleListProvider)(void);
|
||||||
*/
|
*/
|
||||||
RCT_EXTERN NSString *RCTBridgeModuleNameForClass(Class bridgeModuleClass);
|
RCT_EXTERN NSString *RCTBridgeModuleNameForClass(Class bridgeModuleClass);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Experimental.
|
||||||
|
* Check/set if JSI-bound NativeModule is enabled. By default it's off.
|
||||||
|
*/
|
||||||
|
RCT_EXTERN BOOL RCTJSINativeModuleEnabled(void);
|
||||||
|
RCT_EXTERN void RCTEnableJSINativeModule(BOOL enabled);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Async batched bridge used to communicate with the JavaScript application.
|
* Async batched bridge used to communicate with the JavaScript application.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -93,6 +93,16 @@ NSString *RCTBridgeModuleNameForClass(Class cls)
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static BOOL jsiNativeModuleEnabled = NO;
|
||||||
|
BOOL RCTJSINativeModuleEnabled(void)
|
||||||
|
{
|
||||||
|
return jsiNativeModuleEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RCTEnableJSINativeModule(BOOL enabled) {
|
||||||
|
jsiNativeModuleEnabled = enabled;
|
||||||
|
}
|
||||||
|
|
||||||
#if RCT_DEBUG
|
#if RCT_DEBUG
|
||||||
void RCTVerifyAllModulesExported(NSArray *extraModules)
|
void RCTVerifyAllModulesExported(NSArray *extraModules)
|
||||||
{
|
{
|
||||||
|
|
|
@ -289,6 +289,12 @@ RCT_EXTERN void RCTRegisterModule(Class); \
|
||||||
*/
|
*/
|
||||||
+ (BOOL)requiresMainQueueSetup;
|
+ (BOOL)requiresMainQueueSetup;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Experimental.
|
||||||
|
* If YES, this module will be set up via JSI binding instead.
|
||||||
|
*/
|
||||||
|
+ (BOOL)allowJSIBinding;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Injects methods into JS. Entries in this array are used in addition to any
|
* Injects methods into JS. Entries in this array are used in addition to any
|
||||||
* methods defined using the macros above. This method is called only once,
|
* methods defined using the macros above. This method is called only once,
|
||||||
|
|
|
@ -549,6 +549,9 @@ struct RCTInstanceCallback : public InstanceCallback {
|
||||||
NSArray *moduleClassesCopy = [moduleClasses copy];
|
NSArray *moduleClassesCopy = [moduleClasses copy];
|
||||||
NSMutableArray<RCTModuleData *> *moduleDataByID = [NSMutableArray arrayWithCapacity:moduleClassesCopy.count];
|
NSMutableArray<RCTModuleData *> *moduleDataByID = [NSMutableArray arrayWithCapacity:moduleClassesCopy.count];
|
||||||
for (Class moduleClass in moduleClassesCopy) {
|
for (Class moduleClass in moduleClassesCopy) {
|
||||||
|
if (RCTJSINativeModuleEnabled() && [moduleClass respondsToSelector:@selector(allowJSIBinding)] && [moduleClass allowJSIBinding]) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
NSString *moduleName = RCTBridgeModuleNameForClass(moduleClass);
|
NSString *moduleName = RCTBridgeModuleNameForClass(moduleClass);
|
||||||
|
|
||||||
// Check for module name collisions
|
// Check for module name collisions
|
||||||
|
|
Loading…
Reference in New Issue