mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/44376 Changelog: [Internal] In order to make migration a little bit cleaner, I thought it would be nice to implement forward compatibility for RCTCallInvokerModule. This way, the consumer doesn't have to have branching logic when they try to retrieve the callInvoker in their code, and can remove a callsite to the bridge. Reviewed By: RSNara Differential Revision: D56807993 fbshipit-source-id: 6c9aa74db15e04b8ab632d230b3e525363a4d1ca
74 lines
2.4 KiB
Objective-C
74 lines
2.4 KiB
Objective-C
/*
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
#import "RCTBridgeModuleDecorator.h"
|
|
|
|
@implementation RCTBridgeModuleDecorator
|
|
|
|
- (instancetype)initWithViewRegistry:(RCTViewRegistry *)viewRegistry
|
|
moduleRegistry:(RCTModuleRegistry *)moduleRegistry
|
|
bundleManager:(RCTBundleManager *)bundleManager
|
|
callableJSModules:(RCTCallableJSModules *)callableJSModules
|
|
{
|
|
if (self = [super init]) {
|
|
_viewRegistry_DEPRECATED = viewRegistry;
|
|
_moduleRegistry = moduleRegistry;
|
|
_bundleManager = bundleManager;
|
|
_callableJSModules = callableJSModules;
|
|
}
|
|
return self;
|
|
}
|
|
|
|
- (void)attachInteropAPIsToModule:(id<RCTBridgeModule>)bridgeModule
|
|
{
|
|
/**
|
|
* Attach the RCTViewRegistry to this TurboModule, which allows this TurboModule
|
|
* To query a React component's UIView, given its reactTag.
|
|
*
|
|
* Usage: In the TurboModule @implementation, include:
|
|
* `@synthesize viewRegistry_DEPRECATED = _viewRegistry_DEPRECATED`
|
|
*/
|
|
if ([bridgeModule respondsToSelector:@selector(setViewRegistry_DEPRECATED:)]) {
|
|
bridgeModule.viewRegistry_DEPRECATED = _viewRegistry_DEPRECATED;
|
|
}
|
|
|
|
/**
|
|
* Attach the RCTBundleManager to this TurboModule, which allows this TurboModule to
|
|
* read from/write to the app's bundle URL.
|
|
*
|
|
* Usage: In the TurboModule @implementation, include:
|
|
* `@synthesize bundleManager = _bundleManager`
|
|
*/
|
|
if ([bridgeModule respondsToSelector:@selector(setBundleManager:)]) {
|
|
bridgeModule.bundleManager = _bundleManager;
|
|
}
|
|
|
|
/**
|
|
* Attach the RCTCallableJSModules to this TurboModule, which allows this TurboModule
|
|
* to call JS Module methods.
|
|
*
|
|
* Usage: In the TurboModule @implementation, include:
|
|
* `@synthesize callableJSModules = _callableJSModules`
|
|
*/
|
|
if ([bridgeModule respondsToSelector:@selector(setCallableJSModules:)]) {
|
|
bridgeModule.callableJSModules = _callableJSModules;
|
|
}
|
|
|
|
/**
|
|
* Attach the RCTModuleRegistry to this TurboModule, which allows this TurboModule
|
|
* to require other TurboModules/NativeModules.
|
|
*
|
|
* Usage: In the TurboModule @implementation, include:
|
|
* `@synthesize moduleRegistry = _moduleRegistry`
|
|
*/
|
|
if ([bridgeModule respondsToSelector:@selector(setModuleRegistry:)]) {
|
|
bridgeModule.moduleRegistry = _moduleRegistry;
|
|
}
|
|
}
|
|
|
|
@end
|