File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed
Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change 1616#endif
1717
1818@implementation RNZipArchive
19+ {
20+ bool hasListeners;
21+ }
1922
2023@synthesize bridge = _bridge;
2124
2225RCT_EXPORT_MODULE ();
2326
27+ // Will be called when this module's first listener is added.
28+ -(void )startObserving {
29+ hasListeners = YES ;
30+ // Set up any upstream listeners or background tasks as necessary
31+ }
32+
33+ // Will be called when this module's last listener is removed, or on dealloc.
34+ -(void )stopObserving {
35+ hasListeners = NO ;
36+ // Remove upstream listeners, stop unnecessary background tasks
37+ }
38+
2439- (NSArray <NSString *> *)supportedEvents
2540{
2641 return @[@" zipArchiveProgressEvent" ];
@@ -201,7 +216,9 @@ - (void)setProgressHandler {
201216}
202217
203218- (void )dispatchProgessEvent : (float )progress processedFilePath : (NSString *)processedFilePath {
204- [self sendEventWithName: @" zipArchiveProgressEvent" body: @{@" progress" : @(progress), @" filePath" : processedFilePath}];
219+ if (hasListeners) {
220+ [self sendEventWithName: @" zipArchiveProgressEvent" body: @{@" progress" : @(progress), @" filePath" : processedFilePath}];
221+ }
205222}
206223
207224@end
You can’t perform that action at this time.
0 commit comments