diff --git a/React/Base/RCTModuleMethod.m b/React/Base/RCTModuleMethod.m index 3b72f9f06..5f5c9e2dc 100644 --- a/React/Base/RCTModuleMethod.m +++ b/React/Base/RCTModuleMethod.m @@ -102,6 +102,17 @@ static RCTNullability RCTParseNullabilityPostfix(const char **input) return RCTNullabilityUnspecified; } +// returns YES if execution is safe to proceed (enqueue callback invocation), NO if callback has already been invoked +static BOOL RCTCheckCallbackMultipleInvocations(BOOL *didInvoke) { + if (*didInvoke) { + RCTFatal(RCTErrorWithMessage(@"Illegal callback invocation from native module. This callback type only permits a single invocation from native code.")); + return NO; + } else { + *didInvoke = YES; + return YES; + } +} + SEL RCTParseMethodSignature(NSString *, NSArray **); SEL RCTParseMethodSignature(NSString *methodSignature, NSArray **arguments) { @@ -205,8 +216,11 @@ SEL RCTParseMethodSignature(NSString *methodSignature, NSArray