Skip to content

Commit

Permalink
Remove RCTUIManagerObserver from RCTNativeAnimatedTurboModule
Browse files Browse the repository at this point in the history
Reviewed By: philIip

Differential Revision: D32115902

fbshipit-source-id: 27a35ff4b4dad5f6364af6b91a6de9e467c068d0
  • Loading branch information
p-sun authored and facebook-github-bot committed Nov 5, 2021
1 parent b7b59ae commit e9ed115
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 42 deletions.
4 changes: 1 addition & 3 deletions Libraries/NativeAnimation/RCTNativeAnimatedTurboModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,13 @@
#import <React/RCTEventDispatcherProtocol.h>
#import <React/RCTEventEmitter.h>
#import <React/RCTSurfacePresenterStub.h>
#import <React/RCTUIManager.h>
#import <React/RCTUIManagerObserverCoordinator.h>
#import <React/RCTUIManagerUtils.h>

#import "RCTValueAnimatedNode.h"

// 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 <RCTBridgeModule, RCTValueAnimatedNodeObserver, RCTEventDispatcherObserver, RCTUIManagerObserver, RCTSurfacePresenterObserver>
@interface RCTNativeAnimatedTurboModule: RCTEventEmitter <RCTBridgeModule, RCTValueAnimatedNodeObserver, RCTEventDispatcherObserver, RCTSurfacePresenterObserver>

@end
42 changes: 3 additions & 39 deletions Libraries/NativeAnimation/RCTNativeAnimatedTurboModule.mm
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ @implementation RCTNativeAnimatedTurboModule
NSMutableDictionary<NSNumber *, NSNumber *> *_animIdIsManagedByFabric;
// A set of nodeIDs managed by Fabric.
NSMutableSet<NSNumber *> *_nodeIDsManagedByFabric;

}

RCT_EXPORT_MODULE();
Expand All @@ -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];
}
Expand All @@ -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];
}

Expand Down Expand Up @@ -196,8 +187,8 @@ - (void)setSurfacePresenter:(id<RCTSurfacePresenterStub>)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];
}];
}
Expand Down Expand Up @@ -336,33 +327,6 @@ - (void)didMountComponentsWithRootTag:(NSInteger)rootTag
});
}

#pragma mark - RCTUIManagerObserver

- (void)uiManagerWillPerformMounting:(RCTUIManager *)uiManager
{
if (_preOperations.count == 0 && _operations.count == 0) {
return;
}

NSArray<AnimatedOperation> *preOperations = _preOperations;
NSArray<AnimatedOperation> *operations = _operations;
_preOperations = [NSMutableArray new];
_operations = [NSMutableArray new];

[uiManager prependUIBlock:^(__unused RCTUIManager *manager, __unused NSDictionary<NSNumber *, UIView *> *viewRegistry) {
for (AnimatedOperation operation in preOperations) {
operation(self->_nodesManager);
}
}];
[uiManager addUIBlock:^(__unused RCTUIManager *manager, __unused NSDictionary<NSNumber *, UIView *> *viewRegistry) {
for (AnimatedOperation operation in operations) {
operation(self->_nodesManager);
}

[self->_nodesManager updateAnimations];
}];
}

#pragma mark -- Events

- (NSArray<NSString *> *)supportedEvents
Expand Down

0 comments on commit e9ed115

Please sign in to comment.