Skip to content

Commit

Permalink
Avoid oversending modalDismissed event
Browse files Browse the repository at this point in the history
Reviewed By: shergin

Differential Revision: D5895366

fbshipit-source-id: 6d1ca424d2d43fadb48354a1cbad94714448a380
  • Loading branch information
Mehdi Mulani authored and facebook-github-bot committed Sep 23, 2017
1 parent 49359e8 commit 9bf936c
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion React/Views/RCTModalManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@

#import "RCTModalManager.h"

@interface RCTModalManager ()

@property BOOL shouldEmit;

@end

@implementation RCTModalManager

RCT_EXPORT_MODULE();
Expand All @@ -18,9 +24,21 @@ @implementation RCTModalManager
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

0 comments on commit 9bf936c

Please sign in to comment.