Skip to content

Commit fb64a5f

Browse files
RSNarafacebook-github-bot
authored andcommitted
Interop: Implement RCTBridgeProxy registerSegmentWithId (facebook#38299)
Summary: Pull Request resolved: facebook#38299 Bridgeless mode replaces RCTCxxBridge registerSegmentWithId with RCTHost registerSegmentWithId. This diff implements RCTBridgeProxy registerSegmentWithId. Changelog: [Internal] Reviewed By: NickGerleman Differential Revision: D47349027 fbshipit-source-id: b87c395f65ebc8db23ca8e614341227d96435ece
1 parent 55628ac commit fb64a5f

File tree

3 files changed

+22
-13
lines changed

3 files changed

+22
-13
lines changed

packages/react-native/React/Base/RCTBridgeProxy.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
moduleRegistry:(RCTModuleRegistry *)moduleRegistry
2020
bundleManager:(RCTBundleManager *)bundleManager
2121
callableJSModules:(RCTCallableJSModules *)callableJSModules
22-
dispatchToJSThread:(void (^)(dispatch_block_t))dispatchToJSThread NS_DESIGNATED_INITIALIZER;
22+
dispatchToJSThread:(void (^)(dispatch_block_t))dispatchToJSThread
23+
registerSegmentWithId:(void (^)(NSNumber *, NSString *))registerSegmentWithId NS_DESIGNATED_INITIALIZER;
2324

2425
- (NSMethodSignature *)methodSignatureForSelector:(SEL)sel;
2526
- (void)forwardInvocation:(NSInvocation *)invocation;

packages/react-native/React/Base/RCTBridgeProxy.mm

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,15 @@ @implementation RCTBridgeProxy {
2727
RCTBundleManager *_bundleManager;
2828
RCTCallableJSModules *_callableJSModules;
2929
void (^_dispatchToJSThread)(dispatch_block_t);
30+
void (^_registerSegmentWithId)(NSNumber *, NSString *);
3031
}
3132

3233
- (instancetype)initWithViewRegistry:(RCTViewRegistry *)viewRegistry
3334
moduleRegistry:(RCTModuleRegistry *)moduleRegistry
3435
bundleManager:(RCTBundleManager *)bundleManager
3536
callableJSModules:(RCTCallableJSModules *)callableJSModules
3637
dispatchToJSThread:(void (^)(dispatch_block_t))dispatchToJSThread
38+
registerSegmentWithId:(void (^)(NSNumber *, NSString *))registerSegmentWithId
3739
{
3840
self = [super self];
3941
if (self) {
@@ -42,6 +44,7 @@ - (instancetype)initWithViewRegistry:(RCTViewRegistry *)viewRegistry
4244
self->_bundleManager = bundleManager;
4345
self->_callableJSModules = callableJSModules;
4446
self->_dispatchToJSThread = dispatchToJSThread;
47+
self->_registerSegmentWithId = registerSegmentWithId;
4548
}
4649
return self;
4750
}
@@ -159,7 +162,7 @@ - (void)enqueueJSCall:(NSString *)module
159162

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

165168
- (id<RCTBridgeDelegate>)delegate

packages/react-native/ReactCommon/react/bridgeless/platform/ios/Core/RCTInstance.mm

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -225,17 +225,22 @@ - (void)_start
225225
timerManager->setRuntimeExecutor(bufferedRuntimeExecutor);
226226

227227
RCTBridgeProxy *bridgeProxy = RCTTurboModuleInteropEnabled() && RCTTurboModuleInteropBridgeProxyEnabled()
228-
? [[RCTBridgeProxy alloc]
229-
initWithViewRegistry:_bridgeModuleDecorator.viewRegistry_DEPRECATED
230-
moduleRegistry:_bridgeModuleDecorator.moduleRegistry
231-
bundleManager:_bridgeModuleDecorator.bundleManager
232-
callableJSModules:_bridgeModuleDecorator.callableJSModules
233-
dispatchToJSThread:^(dispatch_block_t block) {
234-
__strong __typeof(self) strongSelf = weakSelf;
235-
if (strongSelf && strongSelf->_valid) {
236-
strongSelf->_reactInstance->getBufferedRuntimeExecutor()([=](jsi::Runtime &runtime) { block(); });
237-
}
238-
}]
228+
? [[RCTBridgeProxy alloc] initWithViewRegistry:_bridgeModuleDecorator.viewRegistry_DEPRECATED
229+
moduleRegistry:_bridgeModuleDecorator.moduleRegistry
230+
bundleManager:_bridgeModuleDecorator.bundleManager
231+
callableJSModules:_bridgeModuleDecorator.callableJSModules
232+
dispatchToJSThread:^(dispatch_block_t block) {
233+
__strong __typeof(self) strongSelf = weakSelf;
234+
if (strongSelf && strongSelf->_valid) {
235+
strongSelf->_reactInstance->getBufferedRuntimeExecutor()([=](jsi::Runtime &runtime) { block(); });
236+
}
237+
}
238+
registerSegmentWithId:^(NSNumber *segmentId, NSString *path) {
239+
__strong __typeof(self) strongSelf = weakSelf;
240+
if (strongSelf && strongSelf->_valid) {
241+
[strongSelf registerSegmentWithId:segmentId path:path];
242+
}
243+
}]
239244
: nil;
240245

241246
// Set up TurboModules

0 commit comments

Comments
 (0)