Skip to content

Commit

Permalink
Interop: Implement RCTBridgeProxy registerSegmentWithId
Browse files Browse the repository at this point in the history
Summary:
Bridgeless mode replaces RCTCxxBridge registerSegmentWithId with RCTHost registerSegmentWithId.

This diff implements RCTBridgeProxy registerSegmentWithId.

Changelog: [Internal]

Differential Revision: D47349027

fbshipit-source-id: fcb1428ce2f78226ee433593976fc7efd9f55dc6
  • Loading branch information
RSNara authored and facebook-github-bot committed Jul 11, 2023
1 parent f396067 commit 2dc8c87
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 13 deletions.
3 changes: 2 additions & 1 deletion packages/react-native/React/Base/RCTBridgeProxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
moduleRegistry:(RCTModuleRegistry *)moduleRegistry
bundleManager:(RCTBundleManager *)bundleManager
callableJSModules:(RCTCallableJSModules *)callableJSModules
dispatchToJSThread:(void (^)(dispatch_block_t))dispatchToJSThread NS_DESIGNATED_INITIALIZER;
dispatchToJSThread:(void (^)(dispatch_block_t))dispatchToJSThread
registerSegmentWithId:(void (^)(NSNumber *, NSString *))registerSegmentWithId NS_DESIGNATED_INITIALIZER;

- (NSMethodSignature *)methodSignatureForSelector:(SEL)sel;
- (void)forwardInvocation:(NSInvocation *)invocation;
Expand Down
5 changes: 4 additions & 1 deletion packages/react-native/React/Base/RCTBridgeProxy.mm
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@ @implementation RCTBridgeProxy {
RCTBundleManager *_bundleManager;
RCTCallableJSModules *_callableJSModules;
void (^_dispatchToJSThread)(dispatch_block_t);
void (^_registerSegmentWithId)(NSNumber *, NSString *);
}

- (instancetype)initWithViewRegistry:(RCTViewRegistry *)viewRegistry
moduleRegistry:(RCTModuleRegistry *)moduleRegistry
bundleManager:(RCTBundleManager *)bundleManager
callableJSModules:(RCTCallableJSModules *)callableJSModules
dispatchToJSThread:(void (^)(dispatch_block_t))dispatchToJSThread
registerSegmentWithId:(void (^)(NSNumber *, NSString *))registerSegmentWithId
{
self = [super self];
if (self) {
Expand All @@ -42,6 +44,7 @@ - (instancetype)initWithViewRegistry:(RCTViewRegistry *)viewRegistry
self->_bundleManager = bundleManager;
self->_callableJSModules = callableJSModules;
self->_dispatchToJSThread = dispatchToJSThread;
self->_registerSegmentWithId = registerSegmentWithId;
}
return self;
}
Expand Down Expand Up @@ -159,7 +162,7 @@ - (void)enqueueJSCall:(NSString *)module

- (void)registerSegmentWithId:(NSUInteger)segmentId path:(NSString *)path
{
[self logError:@"Please migrate to RCTHost registerSegmentWithId. Nooping" cmd:_cmd];
self->_registerSegmentWithId(@(segmentId), path);
}

- (id<RCTBridgeDelegate>)delegate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,17 +225,22 @@ - (void)_start
timerManager->setRuntimeExecutor(bufferedRuntimeExecutor);

RCTBridgeProxy *bridgeProxy = RCTTurboModuleInteropEnabled() && RCTTurboModuleInteropBridgeProxyEnabled()
? [[RCTBridgeProxy alloc]
initWithViewRegistry:_bridgeModuleDecorator.viewRegistry_DEPRECATED
moduleRegistry:_bridgeModuleDecorator.moduleRegistry
bundleManager:_bridgeModuleDecorator.bundleManager
callableJSModules:_bridgeModuleDecorator.callableJSModules
dispatchToJSThread:^(dispatch_block_t block) {
__strong __typeof(self) strongSelf = weakSelf;
if (strongSelf && strongSelf->_valid) {
strongSelf->_reactInstance->getBufferedRuntimeExecutor()([=](jsi::Runtime &runtime) { block(); });
}
}]
? [[RCTBridgeProxy alloc] initWithViewRegistry:_bridgeModuleDecorator.viewRegistry_DEPRECATED
moduleRegistry:_bridgeModuleDecorator.moduleRegistry
bundleManager:_bridgeModuleDecorator.bundleManager
callableJSModules:_bridgeModuleDecorator.callableJSModules
dispatchToJSThread:^(dispatch_block_t block) {
__strong __typeof(self) strongSelf = weakSelf;
if (strongSelf && strongSelf->_valid) {
strongSelf->_reactInstance->getBufferedRuntimeExecutor()([=](jsi::Runtime &runtime) { block(); });
}
}
registerSegmentWithId:^(NSNumber *segmentId, NSString *path) {
__strong __typeof(self) strongSelf = weakSelf;
if (strongSelf && strongSelf->_valid) {
[strongSelf registerSegmentWithId:segmentId path:path];
}
}]
: nil;

// Set up TurboModules
Expand Down

0 comments on commit 2dc8c87

Please sign in to comment.