From e9ed115babbc82968380dae22fa928d4ce3cd6da Mon Sep 17 00:00:00 2001 From: Paige Sun Date: Fri, 5 Nov 2021 14:14:18 -0700 Subject: [PATCH] Remove RCTUIManagerObserver from RCTNativeAnimatedTurboModule Reviewed By: philIip Differential Revision: D32115902 fbshipit-source-id: 27a35ff4b4dad5f6364af6b91a6de9e467c068d0 --- .../RCTNativeAnimatedTurboModule.h | 4 +- .../RCTNativeAnimatedTurboModule.mm | 42 ++----------------- 2 files changed, 4 insertions(+), 42 deletions(-) diff --git a/Libraries/NativeAnimation/RCTNativeAnimatedTurboModule.h b/Libraries/NativeAnimation/RCTNativeAnimatedTurboModule.h index 2da04a1277eb1f..49c4dfd94bb873 100644 --- a/Libraries/NativeAnimation/RCTNativeAnimatedTurboModule.h +++ b/Libraries/NativeAnimation/RCTNativeAnimatedTurboModule.h @@ -9,8 +9,6 @@ #import #import #import -#import -#import #import #import "RCTValueAnimatedNode.h" @@ -18,6 +16,6 @@ // TODO T69437152 @petetheheat - Delete this fork when Fabric ships to 100%. // NOTE: This module is temporarily forked (see RCTNativeAnimatedModule). // When making any changes, be sure to apply them to the fork as well. -@interface RCTNativeAnimatedTurboModule: RCTEventEmitter +@interface RCTNativeAnimatedTurboModule: RCTEventEmitter @end diff --git a/Libraries/NativeAnimation/RCTNativeAnimatedTurboModule.mm b/Libraries/NativeAnimation/RCTNativeAnimatedTurboModule.mm index da3659ef933d4b..16986e1b24c10c 100644 --- a/Libraries/NativeAnimation/RCTNativeAnimatedTurboModule.mm +++ b/Libraries/NativeAnimation/RCTNativeAnimatedTurboModule.mm @@ -29,7 +29,6 @@ @implementation RCTNativeAnimatedTurboModule NSMutableDictionary *_animIdIsManagedByFabric; // A set of nodeIDs managed by Fabric. NSMutableSet *_nodeIDsManagedByFabric; - } RCT_EXPORT_MODULE(); @@ -52,15 +51,8 @@ - (instancetype)init - (void)initialize { - if (self.bridge) { - _surfacePresenter = self.bridge.surfacePresenter; - _nodesManager = [[RCTNativeAnimatedNodesManager alloc] initWithBridge:self.bridge surfacePresenter:_surfacePresenter]; - [self.bridge.uiManager.observerCoordinator addObserver:self]; - } else { - // _surfacePresenter set in setSurfacePresenter: - _nodesManager = [[RCTNativeAnimatedNodesManager alloc] initWithBridge:nil surfacePresenter:_surfacePresenter]; - } - + // _surfacePresenter set in setSurfacePresenter: + _nodesManager = [[RCTNativeAnimatedNodesManager alloc] initWithBridge:nil surfacePresenter:_surfacePresenter]; [_surfacePresenter addObserver:self]; [[self.moduleRegistry moduleForName:"EventDispatcher"] addDispatchObserver:self]; } @@ -70,7 +62,6 @@ - (void)invalidate [super invalidate]; [_nodesManager stopAnimationLoop]; [[self.moduleRegistry moduleForName:"EventDispatcher"] removeDispatchObserver:self]; - [self.bridge.uiManager.observerCoordinator removeObserver:self]; [_surfacePresenter removeObserver:self]; } @@ -196,8 +187,8 @@ - (void)setSurfacePresenter:(id)surfacePresenter if (RCTUIManagerTypeForTagIsFabric(@(viewTag))) { [_nodeIDsManagedByFabric addObject:@(nodeTag)]; } - NSString *viewName = [self.bridge.uiManager viewNameForReactTag:[NSNumber numberWithDouble:viewTag]]; [self addOperationBlock:^(RCTNativeAnimatedNodesManager *nodesManager) { + NSString *viewName; // Not used when node is managed by Fabric. Nodes are always managed by Fabric in Bridgeless. [nodesManager connectAnimatedNodeToView:[NSNumber numberWithDouble:nodeTag] viewTag:[NSNumber numberWithDouble:viewTag] viewName:viewName]; }]; } @@ -336,33 +327,6 @@ - (void)didMountComponentsWithRootTag:(NSInteger)rootTag }); } -#pragma mark - RCTUIManagerObserver - -- (void)uiManagerWillPerformMounting:(RCTUIManager *)uiManager -{ - if (_preOperations.count == 0 && _operations.count == 0) { - return; - } - - NSArray *preOperations = _preOperations; - NSArray *operations = _operations; - _preOperations = [NSMutableArray new]; - _operations = [NSMutableArray new]; - - [uiManager prependUIBlock:^(__unused RCTUIManager *manager, __unused NSDictionary *viewRegistry) { - for (AnimatedOperation operation in preOperations) { - operation(self->_nodesManager); - } - }]; - [uiManager addUIBlock:^(__unused RCTUIManager *manager, __unused NSDictionary *viewRegistry) { - for (AnimatedOperation operation in operations) { - operation(self->_nodesManager); - } - - [self->_nodesManager updateAnimations]; - }]; -} - #pragma mark -- Events - (NSArray *)supportedEvents