|
15 | 15 | @class RCTModuleRegistry;
|
16 | 16 | @class RCTViewRegistry;
|
17 | 17 | @class RCTBundleManager;
|
| 18 | +@class RCTCallableJSModules; |
18 | 19 |
|
19 | 20 | /**
|
20 | 21 | * The type of a block that is capable of sending a response to a bridged
|
@@ -146,6 +147,17 @@ RCT_EXTERN_C_END
|
146 | 147 | */
|
147 | 148 | @property (nonatomic, weak, readwrite) RCTBundleManager *bundleManager;
|
148 | 149 |
|
| 150 | +/** |
| 151 | + * A reference to an RCTCallableJSModules. Useful for modules that need to |
| 152 | + * call into methods on JavaScript modules registered as callable with |
| 153 | + * React Native. |
| 154 | + * |
| 155 | + * To implement this in your module, just add `@synthesize callableJSModules = |
| 156 | + * _callableJSModules;`. If using Swift, add `@objc var callableJSModules: |
| 157 | + * RCTCallableJSModules!` to your module. |
| 158 | + */ |
| 159 | +@property (nonatomic, weak, readwrite) RCTCallableJSModules *callableJSModules; |
| 160 | + |
149 | 161 | /**
|
150 | 162 | * A reference to the RCTBridge. Useful for modules that require access
|
151 | 163 | * to bridge features, such as sending events or making JS calls. This
|
@@ -443,3 +455,24 @@ typedef UIView * (^RCTBridgelessComponentViewProvider)(NSNumber *);
|
443 | 455 |
|
444 | 456 | - (UIView *)viewForReactTag:(NSNumber *)reactTag;
|
445 | 457 | @end
|
| 458 | + |
| 459 | +typedef void (^RCTBridgelessJSModuleMethodInvoker)( |
| 460 | + NSString *moduleName, |
| 461 | + NSString *methodName, |
| 462 | + NSArray *args, |
| 463 | + dispatch_block_t onComplete); |
| 464 | + |
| 465 | +/** |
| 466 | + * A class that allows NativeModules to call methods on JavaScript modules registered |
| 467 | + * as callable with React Native. |
| 468 | + */ |
| 469 | +@interface RCTCallableJSModules : NSObject |
| 470 | +- (void)setBridge:(RCTBridge *)bridge; |
| 471 | +- (void)setBridgelessJSModuleMethodInvoker:(RCTBridgelessJSModuleMethodInvoker)bridgelessJSModuleMethodInvoker; |
| 472 | + |
| 473 | +- (void)invokeModule:(NSString *)moduleName method:(NSString *)methodName withArgs:(NSArray *)args; |
| 474 | +- (void)invokeModule:(NSString *)moduleName |
| 475 | + method:(NSString *)methodName |
| 476 | + withArgs:(NSArray *)args |
| 477 | + onComplete:(dispatch_block_t)onComplete; |
| 478 | +@end |
0 commit comments