Skip to content

Commit

Permalink
completeHandlerIOS now return a promise so you can await for it
Browse files Browse the repository at this point in the history
  • Loading branch information
Elad Gil committed Sep 4, 2017
1 parent f58f726 commit fefd456
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion FS.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ var RNFS = {
},

completeHandlerIOS(jobId: number): void {
RNFSManager.completeHandlerIOS(jobId);
return RNFSManager.completeHandlerIOS(jobId);
},

readDir(dirpath: string): Promise<ReadDirItem[]> {
Expand Down
6 changes: 4 additions & 2 deletions RNFSManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -508,17 +508,19 @@ - (dispatch_queue_t)methodQueue
}
}

RCT_EXPORT_METHOD(completeHandlerIOS:(nonnull NSNumber *)jobId)
RCT_EXPORT_METHOD(completeHandlerIOS:(nonnull NSNumber *)jobId
resolver:(RCTPromiseResolveBlock)resolve
rejecter:(RCTPromiseRejectBlock)reject)
{
if (self.uuids) {
NSString *uuid = [self.uuids objectForKey:[jobId stringValue]];
CompletionHandler completionHandler = [completionHandlers objectForKey:uuid];
if (completionHandler) {
NSLog(@"Calling completion handler on: %@", uuid);
completionHandler();
[completionHandlers removeObjectForKey:uuid];
}
}
resolve(nil);
}

RCT_EXPORT_METHOD(uploadFiles:(NSDictionary *)options
Expand Down

0 comments on commit fefd456

Please sign in to comment.