mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Remove RCTRootView.bridge usage from RCTBaseViewController
Summary: RCTBaseViewController uses RCTRootView.bridge to call RCTViewEventEmitter.emit. ## Changes - RCTEventDispatcher now exposes a method to dispatch RCTViewEventEmitter events. - RCTRootView (for paper), and RCTSurfaceHostingProxyRootView (for fabric and bridgeless mode) now exports the RCTEventDispatcher by grabbing it from the bridge - RCTBaseViewController now uses the event dispatcher exported from RCTRootView to dispatch the RCTViewEventEmitter event. ## Benefits - RCTBaseViewController no longer uses the bridge to dispatch RCTViewEventEmitter events - In the future, we'll make RCTSurfaceHostingProxyRootView work with bridgeless mode, which'll allow us to remove the bridge/bridgeless fork in RCTBaseViewController. Changelog: [Internal] Reviewed By: sammy-SC Differential Revision: D30434884 fbshipit-source-id: d961a56ac2abc08a661f8fe7c37926f219b731d0
This commit is contained in:
committed by
Facebook GitHub Bot
parent
bfead74e69
commit
9f69c922cb
@@ -81,6 +81,8 @@ typedef NS_ENUM(NSInteger, RCTTextEventType) {
|
||||
*/
|
||||
@protocol RCTEventDispatcherProtocol <RCTBridgeModule, RCTJSDispatcherModule>
|
||||
|
||||
- (void)sendViewEventWithName:(NSString *)name reactTag:(NSNumber *)reactTag;
|
||||
|
||||
/**
|
||||
* Deprecated, do not use.
|
||||
*/
|
||||
|
||||
@@ -88,6 +88,8 @@ extern
|
||||
*/
|
||||
@property (nonatomic, strong, readonly) RCTModuleRegistry *moduleRegistry;
|
||||
|
||||
@property (nonatomic, strong, readonly) id<RCTEventDispatcherProtocol> eventDispatcher;
|
||||
|
||||
/**
|
||||
* The name of the JavaScript module to execute within the
|
||||
* specified scriptURL (required). Setting this will not have
|
||||
|
||||
@@ -126,6 +126,11 @@ RCT_NOT_IMPLEMENTED(-(instancetype)initWithCoder : (NSCoder *)aDecoder)
|
||||
return _bridge.moduleRegistry;
|
||||
}
|
||||
|
||||
- (id<RCTEventDispatcherProtocol>)eventDispatcher
|
||||
{
|
||||
return [self.moduleRegistry moduleForName:"EventDispatcher"];
|
||||
}
|
||||
|
||||
#pragma mark - passThroughTouches
|
||||
|
||||
- (BOOL)passThroughTouches
|
||||
|
||||
@@ -28,6 +28,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
@property (nonatomic, strong, readonly) RCTBridge *bridge;
|
||||
@property (nonatomic, readonly) BOOL hasBridge;
|
||||
@property (nonatomic, strong, readonly) RCTModuleRegistry *moduleRegistry;
|
||||
@property (nonatomic, strong, readonly) id<RCTEventDispatcherProtocol> eventDispatcher;
|
||||
@property (nonatomic, copy, readwrite) NSDictionary *appProperties;
|
||||
@property (nonatomic, assign) RCTRootViewSizeFlexibility sizeFlexibility;
|
||||
@property (nonatomic, weak) id<RCTRootViewDelegate> delegate;
|
||||
|
||||
@@ -104,6 +104,11 @@ static RCTRootViewSizeFlexibility convertToRootViewSizeFlexibility(RCTSurfaceSiz
|
||||
return _bridge.moduleRegistry;
|
||||
}
|
||||
|
||||
- (id<RCTEventDispatcherProtocol>)eventDispatcher
|
||||
{
|
||||
return [self.moduleRegistry moduleForName:"EventDispatcher"];
|
||||
}
|
||||
|
||||
RCT_NOT_IMPLEMENTED(-(instancetype)initWithFrame : (CGRect)frame)
|
||||
RCT_NOT_IMPLEMENTED(-(instancetype)initWithCoder : (NSCoder *)aDecoder)
|
||||
|
||||
|
||||
@@ -56,6 +56,11 @@ RCT_EXPORT_MODULE()
|
||||
_observersLock = [NSLock new];
|
||||
}
|
||||
|
||||
- (void)sendViewEventWithName:(NSString *)name reactTag:(NSNumber *)reactTag
|
||||
{
|
||||
[_callableJSModules invokeModule:@"RCTViewEventEmitter" method:@"emit" withArgs:@[ name, RCTNullIfNil(reactTag) ]];
|
||||
}
|
||||
|
||||
- (void)sendAppEventWithName:(NSString *)name body:(id)body
|
||||
{
|
||||
[_callableJSModules invokeModule:@"RCTNativeAppEventEmitter"
|
||||
|
||||
Reference in New Issue
Block a user