Added RCTJSINativeModule protocol to allow enabling JSI-bound nativemodule
Summary: Instead of asking existing modules to implement `+allowJSIBinding`, introduce a temporary "empty" protocol so modules can just adopt it for migration purpose. Eventually this protocol may just go away. Modules need to adopt both `RCTBridgeModule` and `RCTJSINativeModule` for time being for backward compatibility. p.s. the entire system isn't enabled yet, this is just some of the pre-reqs for NativeModule improvements. Reviewed By: mmmulani Differential Revision: D9762913 fbshipit-source-id: 470f640f11a5991e5cfa9c48a1931da660ebfcd2
This commit is contained in:
parent
adaeba296e
commit
6052e97ba7
|
@ -289,12 +289,6 @@ RCT_EXTERN void RCTRegisterModule(Class); \
|
|||
*/
|
||||
+ (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
|
||||
* methods defined using the macros above. This method is called only once,
|
||||
|
@ -327,3 +321,12 @@ RCT_EXTERN void RCTRegisterModule(Class); \
|
|||
- (void)partialBatchDidFlush;
|
||||
|
||||
@end
|
||||
|
||||
/**
|
||||
* Experimental.
|
||||
* A protocol to declare that a class supports JSI-bound NativeModule.
|
||||
* This may be removed in the future.
|
||||
*/
|
||||
@protocol RCTJSINativeModule <NSObject>
|
||||
|
||||
@end
|
||||
|
|
|
@ -549,7 +549,7 @@ struct RCTInstanceCallback : public InstanceCallback {
|
|||
NSArray *moduleClassesCopy = [moduleClasses copy];
|
||||
NSMutableArray<RCTModuleData *> *moduleDataByID = [NSMutableArray arrayWithCapacity:moduleClassesCopy.count];
|
||||
for (Class moduleClass in moduleClassesCopy) {
|
||||
if (RCTJSINativeModuleEnabled() && [moduleClass respondsToSelector:@selector(allowJSIBinding)] && [moduleClass allowJSIBinding]) {
|
||||
if (RCTJSINativeModuleEnabled() && [moduleClass conformsToProtocol:@protocol(RCTJSINativeModule)]) {
|
||||
continue;
|
||||
}
|
||||
NSString *moduleName = RCTBridgeModuleNameForClass(moduleClass);
|
||||
|
|
Loading…
Reference in New Issue