Rollout RCTValidateCanSendEventInRCTEventEmitter (#41261)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41261

Replaces a previous soft error with an RCTAssert.

Changelog: [Internal]

Reviewed By: RSNara

Differential Revision: D50641816

fbshipit-source-id: 06ef83d058169b3a73ad8179a778d32dff8db80d
This commit is contained in:
Pieter De Baets
2023-10-31 07:09:46 -07:00
committed by Facebook GitHub Bot
parent 9a3b75c782
commit da5eb3efe3
5 changed files with 2 additions and 41 deletions
@@ -49,12 +49,6 @@ RCT_EXTERN NSString *const RCTDidInitializeModuleNotification;
RCT_EXTERN BOOL RCTGetDispatchW3CPointerEvents(void);
RCT_EXTERN void RCTSetDispatchW3CPointerEvents(BOOL value);
/*
* Validate RCTEventEmitter
*/
RCT_EXTERN BOOL RCTGetValidateCanSendEventInRCTEventEmitter(void);
RCT_EXTERN void RCTSetValidateCanSendEventInRCTEventEmitter(BOOL value);
/*
* Memory Pressure Unloading Level
*/
@@ -36,21 +36,6 @@ void RCTSetDispatchW3CPointerEvents(BOOL value)
RCTDispatchW3CPointerEvents = value;
}
/*
* Validate RCTEventEmitter. For experimentation only.
*/
static BOOL RCTValidateCanSendEventInRCTEventEmitter = NO;
BOOL RCTGetValidateCanSendEventInRCTEventEmitter(void)
{
return RCTValidateCanSendEventInRCTEventEmitter;
}
void RCTSetValidateCanSendEventInRCTEventEmitter(BOOL value)
{
RCTValidateCanSendEventInRCTEventEmitter = value;
}
/*
* Memory Pressure Unloading Level for experimentation only.
* Default is 15, which is TRIM_MEMORY_RUNNING_CRITICAL.
@@ -107,9 +107,7 @@ RCT_EXPORT_MODULE()
- (void)handleMemoryWarning
{
if ([self canSendEvents_DEPRECATED]) {
[self sendEventWithName:@"memoryWarning" body:nil];
}
[self sendEventWithName:@"memoryWarning" body:nil];
}
- (void)handleAppStateDidChange:(NSNotification *)notification
@@ -126,9 +124,7 @@ RCT_EXPORT_MODULE()
if (![newState isEqualToString:_lastKnownState]) {
_lastKnownState = newState;
if ([self canSendEvents_DEPRECATED]) {
[self sendEventWithName:@"appStateDidChange" body:@{@"app_state" : _lastKnownState}];
}
[self sendEventWithName:@"appStateDidChange" body:@{@"app_state" : _lastKnownState}];
}
}
@@ -32,8 +32,6 @@
*/
- (void)sendEventWithName:(NSString *)name body:(id)body;
- (BOOL)canSendEvents_DEPRECATED;
/**
* These methods will be called when the first observer is added and when the
* last observer is removed (or when dealloc is called), respectively. These
@@ -71,18 +71,6 @@
}
}
/* TODO: (T118587955) Remove canSendEvents_DEPRECATED and validate RCTEventEmitter does not fail
* RCTAssert in _callableJSModules when the React Native instance is invalidated.
*/
- (BOOL)canSendEvents_DEPRECATED
{
bool canSendEvents = _callableJSModules != nil;
if (!canSendEvents && RCTGetValidateCanSendEventInRCTEventEmitter()) {
RCTLogError(@"Trying to send event when _callableJSModules is nil.");
}
return canSendEvents;
}
- (void)startObserving
{
// Does nothing