Permalink
Browse files

Fix double completion callback in RCTJavascriptLoader

Reviewed By: foghina, mmmulani

Differential Revision: D3541511

fbshipit-source-id: 9a0a4be635ca910cb1a5c875a0f4a2b82c51cf71
  • Loading branch information...
1 parent c0316c6 commit 4aedcc767095bd5fd33a643e68311920ea18a5f5 @javache javache committed with Facebook Github Bot 8 Jul 10, 2016
Showing with 9 additions and 10 deletions.
  1. +9 −10 React/Base/RCTJavaScriptLoader.m
@@ -60,7 +60,6 @@ + (void)loadBundleAtURL:(NSURL *)scriptURL onComplete:(RCTSourceLoadBlock)onComp
}
magicNumber = NSSwapLittleIntToHost(magicNumber);
-
if (magicNumber == RCTRAMBundleMagicNumber) {
NSData *source = [NSData dataWithBytes:&magicNumber length:sizeof(magicNumber)];
NSError *error = nil;
@@ -73,16 +72,16 @@ + (void)loadBundleAtURL:(NSURL *)scriptURL onComplete:(RCTSourceLoadBlock)onComp
sourceLength = statInfo.st_size;
}
onComplete(error, source, sourceLength);
+ } else {
+ // Reading in a large bundle can be slow. Dispatch to the background queue to do it.
+ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+ NSError *error = nil;
+ NSData *source = [NSData dataWithContentsOfFile:scriptURL.path
+ options:NSDataReadingMappedIfSafe
+ error:&error];
+ onComplete(error, source, source.length);
+ });
}
-
- // Reading in a large bundle can be slow. Dispatch to the background queue to do it.
- dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
- NSError *error = nil;
- NSData *source = [NSData dataWithContentsOfFile:scriptURL.path
- options:NSDataReadingMappedIfSafe
- error:&error];
- onComplete(error, source, source.length);
- });
return;
}

0 comments on commit 4aedcc7

Please sign in to comment.