Avoid oversending modalDismissed event

Reviewed By: shergin

Differential Revision: D5895366

fbshipit-source-id: 6d1ca424d2d43fadb48354a1cbad94714448a380
This commit is contained in:
Mehdi Mulani 2017-09-23 10:34:27 -07:00 committed by Facebook Github Bot
parent 49359e879b
commit 9bf936ccba
1 changed files with 19 additions and 1 deletions

View File

@ -9,6 +9,12 @@
#import "RCTModalManager.h"
@interface RCTModalManager ()
@property BOOL shouldEmit;
@end
@implementation RCTModalManager
RCT_EXPORT_MODULE();
@ -18,9 +24,21 @@ RCT_EXPORT_MODULE();
return @[ @"modalDismissed" ];
}
- (void)startObserving
{
_shouldEmit = YES;
}
- (void)stopObserving
{
_shouldEmit = NO;
}
- (void)modalDismissed:(NSNumber *)modalID
{
[self sendEventWithName:@"modalDismissed" body:@{ @"modalID": modalID }];
if (_shouldEmit) {
[self sendEventWithName:@"modalDismissed" body:@{ @"modalID": modalID }];
}
}
@end