From aef0ef4b31ffa4e22e2054bc61461ceacc96d09c Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Fri, 3 Apr 2020 09:44:40 -0700 Subject: [PATCH] Export Instance::getDecoratedNativeCallInvoker from RCTCxxBridge Summary: `RCTTurboModuleManager` will create a native `CallInvoker` for each ObjC NativeModule. This `CallInvoker` will be used to dispatch calls from JS to native. Before passing the native `CallInvoker` to the `ObjCTurboModule`, it'll first use `RCTCxxBridge decorateNativeCallInvoker` to get a bridge-aware decorated native `CallInvoker`. That way, the bridge remains informed about async TurboModule method calls that took place since the last time it was flushed. This ensures that we don't end up dispatching `onBatchComplete` any less with TurboModules on than we do with TurboModules off. Changelog: [Internal] Reviewed By: fkgozali Differential Revision: D20831546 fbshipit-source-id: b2eb4e0097e0dabf8c4bd8fdc4c850a0858af699 --- React/CxxBridge/RCTCxxBridge.mm | 17 ++++++++++++----- .../core/platform/ios/RCTTurboModule.h | 4 +++- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/React/CxxBridge/RCTCxxBridge.mm b/React/CxxBridge/RCTCxxBridge.mm index 2b25e227f9b..d8938d7033a 100644 --- a/React/CxxBridge/RCTCxxBridge.mm +++ b/React/CxxBridge/RCTCxxBridge.mm @@ -210,11 +210,6 @@ struct RCTInstanceCallback : public InstanceCallback { return _jsMessageThread; } -- (std::shared_ptr)jsCallInvoker -{ - return _reactInstance ? _reactInstance->getJSCallInvoker() : nullptr; -} - - (BOOL)isInspectable { return _reactInstance ? _reactInstance->isInspectable() : NO; @@ -1450,4 +1445,16 @@ RCT_NOT_IMPLEMENTED(-(instancetype)initWithBundleURL }]; } +#pragma mark - RCTBridge (RCTTurboModule) + +- (std::shared_ptr)jsCallInvoker +{ + return _reactInstance ? _reactInstance->getJSCallInvoker() : nullptr; +} + +- (std::shared_ptr)decorateNativeCallInvoker:(std::shared_ptr)nativeInvoker +{ + return _reactInstance ? _reactInstance->getDecoratedNativeCallInvoker(nativeInvoker) : nullptr; +} + @end diff --git a/ReactCommon/turbomodule/core/platform/ios/RCTTurboModule.h b/ReactCommon/turbomodule/core/platform/ios/RCTTurboModule.h index 49844e1f534..e419f66a6de 100644 --- a/ReactCommon/turbomodule/core/platform/ios/RCTTurboModule.h +++ b/ReactCommon/turbomodule/core/platform/ios/RCTTurboModule.h @@ -221,6 +221,8 @@ class JSI_EXPORT ObjCTurboModule : public TurboModule { * * TODO: Consolidate this extension with the one in RCTSurfacePresenter. */ -@interface RCTBridge () +@interface RCTBridge (RCTTurboModule) - (std::shared_ptr)jsCallInvoker; +- (std::shared_ptr)decorateNativeCallInvoker: + (std::shared_ptr)nativeInvoker; @end