Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions lib/ios/RNNEventEmitter.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#import "RNNEventEmitter.h"

@implementation RNNEventEmitter
@implementation RNNEventEmitter {
NSInteger _appLaunchedListenerCount;
BOOL _appLaunchedEventDeferred;
}

RCT_EXPORT_MODULE();

Expand All @@ -16,7 +19,11 @@ @implementation RNNEventEmitter
# pragma mark public

-(void)sendOnAppLaunched {
[self send:onAppLaunched body:nil];
if (_appLaunchedListenerCount > 0) {
[self send:onAppLaunched body:nil];
} else {
_appLaunchedEventDeferred = TRUE;
}
}

-(void)sendContainerDidAppear:(NSString *)containerId {
Expand All @@ -31,6 +38,17 @@ -(void)sendOnNavigationButtonPressed:(NSString *)containerId buttonId:(NSString*
[self send:onNavigationButtonPressed body:@{@"containerId":containerId , @"buttonId": buttonId }];
}

- (void)addListener:(NSString *)eventName {
[super addListener:eventName];
if ([eventName isEqualToString:onAppLaunched]) {
_appLaunchedListenerCount++;
if (_appLaunchedEventDeferred) {
_appLaunchedEventDeferred = FALSE;
[self sendOnAppLaunched];
}
}
}

# pragma mark private

-(void)send:(NSString *)eventName body:(id)body {
Expand Down