Fix - argument type in RCTEventEmitter

Reviewed By: javache

Differential Revision: D6528139

fbshipit-source-id: 170c2359bcc67131330d091e3707124018053938
This commit is contained in:
Rahul Ramachandran 2017-12-13 08:25:09 -08:00 committed by Facebook Github Bot
parent fbf0aed3ac
commit eaa84997ce
2 changed files with 5 additions and 4 deletions

View File

@ -39,6 +39,6 @@
- (void)stopObserving;
- (void)addListener:(NSString *)eventName;
- (void)removeListeners:(NSInteger)count;
- (void)removeListeners:(double)count;
@end

View File

@ -84,12 +84,13 @@ RCT_EXPORT_METHOD(addListener:(NSString *)eventName)
}
}
RCT_EXPORT_METHOD(removeListeners:(NSInteger)count)
RCT_EXPORT_METHOD(removeListeners:(double)count)
{
if (RCT_DEBUG && count > _listenerCount) {
int currentCount = (int)count;
if (RCT_DEBUG && currentCount > _listenerCount) {
RCTLogError(@"Attempted to remove more %@ listeners than added", [self class]);
}
_listenerCount = MAX(_listenerCount - count, 0);
_listenerCount = MAX(_listenerCount - currentCount, 0);
if (_listenerCount == 0) {
[self stopObserving];
}