Back out "Remove _shouldEmitEvent guardrails"

Summary:
Backout of this [commit]() as the previous one was making some E2E fail and need to investigate further.

## Changelog:
[Internal] - Add back `_shouldEmitEvent` guardrails

Reviewed By: mdvacca, arushikesarwani94

Differential Revision: D60467145

fbshipit-source-id: a703022aa74ca0ed0fed05b59da68918eb2001e1
This commit is contained in:
Riccardo Cipolleschi
2024-07-30 13:06:15 -07:00
committed by Facebook GitHub Bot
parent 48421df60a
commit 488faaaddb
@@ -27,6 +27,9 @@ typedef void (^AnimatedOperation)(RCTNativeAnimatedNodesManager *nodesManager);
NSMutableArray<AnimatedOperation> *_preOperations;
NSSet<NSString *> *_userDrivenAnimationEndedEvents;
// TODO: Remove this when https://github.com/facebook/react-native/pull/45457 lands
BOOL _shouldEmitEvent;
}
RCT_EXPORT_MODULE();
@@ -42,6 +45,7 @@ RCT_EXPORT_MODULE();
_operations = [NSMutableArray new];
_preOperations = [NSMutableArray new];
_userDrivenAnimationEndedEvents = [NSSet setWithArray:@[ @"onScrollEnded" ]];
_shouldEmitEvent = NO;
}
return self;
}
@@ -375,8 +379,27 @@ RCT_EXPORT_METHOD(queueAndExecuteBatchedOperations : (NSArray *)operationsAndArg
[self sendEventWithName:@"onAnimatedValueUpdate" body:@{@"tag" : node.nodeTag, @"value" : @(value)}];
}
// TODO: Remove this when https://github.com/facebook/react-native/pull/45457 lands
- (void)startObserving
{
[super startObserving];
_shouldEmitEvent = YES;
}
- (void)stopObserving
{
[super stopObserving];
_shouldEmitEvent = NO;
}
// ----
- (void)userDrivenAnimationEnded:(NSArray<NSNumber *> *)nodes
{
if (!_shouldEmitEvent) {
return;
}
[self sendEventWithName:@"onUserDrivenAnimationEnded" body:@{@"tags" : nodes}];
}