Skip to content

Commit 422c224

Browse files
p-sunfacebook-github-bot
authored andcommitted
Add MC to check whether canSendEvents_DEPRECATED is needed
Summary: Changelog: [Internal] See T118587955 Reviewed By: RSNara Differential Revision: D36026423 fbshipit-source-id: 26cfcf318af4a5061e94bd0286c0433c06886d8e
1 parent f9922a3 commit 422c224

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

React/Base/RCTConstants.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ RCT_EXTERN BOOL RCTGetDispatchW3CPointerEvents(void);
2323
RCT_EXTERN void RCTSetDispatchW3CPointerEvents(BOOL value);
2424

2525
/*
26-
* Memory Pressure Unloading
26+
* Validate RCTEventEmitter
2727
*/
28-
RCT_EXTERN BOOL RCTGetDisableBridgeMemoryPressureUnload(void);
29-
RCT_EXTERN void RCTSetDisableBridgeMemoryPressureUnload(BOOL value);
28+
RCT_EXTERN BOOL RCTGetValidateCanSendEventInRCTEventEmitter(void);
29+
RCT_EXTERN void RCTSetValidateCanSendEventInRCTEventEmitter(BOOL value);
3030

3131
/*
3232
* Memory Pressure Unloading Level

React/Base/RCTConstants.m

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,18 @@ void RCTSetDispatchW3CPointerEvents(BOOL value)
4141
}
4242

4343
/*
44-
* Memory Pressure Unloading
44+
* Validate RCTEventEmitter. For experimentation only.
4545
*/
46-
static BOOL RCTDisableBridgeMemoryPressureUnload = NO;
46+
static BOOL RCTValidateCanSendEventInRCTEventEmitter = NO;
4747

48-
BOOL RCTGetDisableBridgeMemoryPressureUnload()
48+
BOOL RCTGetValidateCanSendEventInRCTEventEmitter()
4949
{
50-
return RCTDisableBridgeMemoryPressureUnload;
50+
return RCTValidateCanSendEventInRCTEventEmitter;
5151
}
5252

53-
void RCTSetDisableBridgeMemoryPressureUnload(BOOL value)
53+
void RCTSetValidateCanSendEventInRCTEventEmitter(BOOL value)
5454
{
55-
RCTDisableBridgeMemoryPressureUnload = value;
55+
RCTValidateCanSendEventInRCTEventEmitter = value;
5656
}
5757

5858
/*

React/Modules/RCTEventEmitter.m

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*/
77

88
#import "RCTEventEmitter.h"
9+
#import <React/RCTConstants.h>
910
#import "RCTAssert.h"
1011
#import "RCTLog.h"
1112
#import "RCTUtils.h"
@@ -83,7 +84,11 @@ - (void)sendEventWithName:(NSString *)eventName body:(id)body
8384
*/
8485
- (BOOL)canSendEvents_DEPRECATED
8586
{
86-
return _callableJSModules != nil;
87+
bool canSendEvents = _callableJSModules != nil;
88+
if (!canSendEvents && RCTGetValidateCanSendEventInRCTEventEmitter()) {
89+
RCTLogError(@"Trying to send event when _callableJSModules is nil.");
90+
}
91+
return canSendEvents;
8792
}
8893

8994
- (void)startObserving

0 commit comments

Comments
 (0)