Files
react-native/React/Base/RCTBridgeModuleDecorator.h
T
Paige Sun 94b1b8a573 1/5 Refactor CxxBridge: Introduce RCTBridgeModuleDecorator to attach @synthesize ivars to RCTTurboModules, in Bridge mode
Summary:
Changelog: [iOS][Internal] Refactor CxxBridge: Introduce RCTBridgeModuleDecorator to attach synthesize ivars to RCTTurboModules, in Bridge mode

This doesn't change any logic. RCTBridgeModuleDecorator was created to consolidate several nearly identical implementations of the `attachInteropAPIsToModule` method to one place.

Most importantly, it allows us to attach interop APIs in RCTBridgeModuleDecorator to RCTViewManagers in diff 4/4, using  `attachInteropAPIsToModule`. Before this stack, these four synthesize ivars in RCTViewManagers are nil in Bridgeless mode, and point to instances in Bridge mode.

# Context
These are used in RCTBridgeModules to access APIs for view managers. These APIs are necessary and compatible with Bridgeless mode.

*  synthesize viewRegistry_DEPRECATED
*  synthesize bundleManager
*  synthesize callableJSModules
*  synthesize moduleRegistry

Reviewed By: RSNara

Differential Revision: D34437802

fbshipit-source-id: b773d511cf877d4896436fabf4893c978e5f8dd9
2022-02-25 08:50:34 -08:00

36 lines
1.3 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 "RCTBridgeModule.h"
@class RCTBundleManager;
@class RCTCallableJSModules;
@class RCTModuleRegistry;
@class RCTViewRegistry;
/**
RCTBridgeModuleDecorator contains instances that can be intialized with @synthesize
in RCTBridgeModules. For the Fabric interop layer.
In Bridgeless, @synthesize ivars are passed from RCTBridgeModuleDecorator.
In Bridge, @synthesize ivars are passed from RCTModuleData.
*/
@interface RCTBridgeModuleDecorator : NSObject
@property (nonatomic, strong, readonly) RCTViewRegistry *viewRegistry_DEPRECATED;
@property (nonatomic, strong, readonly) RCTModuleRegistry *moduleRegistry;
@property (nonatomic, strong, readonly) RCTBundleManager *bundleManager;
@property (nonatomic, strong, readonly) RCTCallableJSModules *callableJSModules;
- (instancetype)initWithViewRegistry:(RCTViewRegistry *)viewRegistry
moduleRegistry:(RCTModuleRegistry *)moduleRegistry
bundleManager:(RCTBundleManager *)bundleManager
callableJSModules:(RCTCallableJSModules *)callableJSModules;
- (void)attachInteropAPIsToModule:(id<RCTBridgeModule>)bridgeModule;
@end