Skip to content

Commit

Permalink
Export Instance::getDecoratedNativeCallInvoker from RCTCxxBridge
Browse files Browse the repository at this point in the history
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
  • Loading branch information
RSNara authored and facebook-github-bot committed Apr 3, 2020
1 parent de56649 commit aef0ef4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
17 changes: 12 additions & 5 deletions React/CxxBridge/RCTCxxBridge.mm
Original file line number Diff line number Diff line change
Expand Up @@ -210,11 +210,6 @@ - (void)setRCTTurboModuleLookupDelegate:(id<RCTTurboModuleLookupDelegate>)turboM
return _jsMessageThread;
}

- (std::shared_ptr<CallInvoker>)jsCallInvoker
{
return _reactInstance ? _reactInstance->getJSCallInvoker() : nullptr;
}

- (BOOL)isInspectable
{
return _reactInstance ? _reactInstance->isInspectable() : NO;
Expand Down Expand Up @@ -1450,4 +1445,16 @@ - (void)invokeAsync:(std::function<void()> &&)func
}];
}

#pragma mark - RCTBridge (RCTTurboModule)

- (std::shared_ptr<CallInvoker>)jsCallInvoker
{
return _reactInstance ? _reactInstance->getJSCallInvoker() : nullptr;
}

- (std::shared_ptr<CallInvoker>)decorateNativeCallInvoker:(std::shared_ptr<CallInvoker>)nativeInvoker
{
return _reactInstance ? _reactInstance->getDecoratedNativeCallInvoker(nativeInvoker) : nullptr;
}

@end
4 changes: 3 additions & 1 deletion ReactCommon/turbomodule/core/platform/ios/RCTTurboModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<facebook::react::CallInvoker>)jsCallInvoker;
- (std::shared_ptr<facebook::react::CallInvoker>)decorateNativeCallInvoker:
(std::shared_ptr<facebook::react::CallInvoker>)nativeInvoker;
@end

0 comments on commit aef0ef4

Please sign in to comment.