From 8f51c19bdab16b58a98497ae9856d18a97e4f8b9 Mon Sep 17 00:00:00 2001 From: Ruben Niculcea Date: Sun, 7 Jun 2015 14:55:14 -0700 Subject: [PATCH 1/3] Allow live reload even on errors. --- React/Base/RCTBridge.m | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/React/Base/RCTBridge.m b/React/Base/RCTBridge.m index 998fb7bca59d09..6d093ee36aa6f1 100644 --- a/React/Base/RCTBridge.m +++ b/React/Base/RCTBridge.m @@ -1061,6 +1061,8 @@ - (void)initJS RCTJavaScriptLoader *loader = [[RCTJavaScriptLoader alloc] initWithBridge:self]; [loader loadBundleAtURL:bundleURL onComplete:^(NSError *error, NSString *script) { + + [[RCTRedBox sharedInstance] dismiss]; _loading = NO; if (!self.isValid) { @@ -1085,6 +1087,17 @@ - (void)initJS [[NSNotificationCenter defaultCenter] postNotificationName:RCTJavaScriptDidFailToLoadNotification object:_parentBridge userInfo:userInfo]; + + /** + * Register the display link to start sending js calls after everything + * is setup + */ + NSRunLoop *targetRunLoop = [_javaScriptExecutor isKindOfClass:[RCTContextExecutor class]] ? [NSRunLoop currentRunLoop] : [NSRunLoop mainRunLoop]; + [_jsDisplayLink addToRunLoop:targetRunLoop forMode:NSRunLoopCommonModes]; + + [[NSNotificationCenter defaultCenter] postNotificationName:RCTJavaScriptDidLoadNotification + object:_parentBridge + userInfo:@{ @"bridge": self }]; } else { From 3e2034dd044c8b4adcd2eca0b17301e1d5acdbc1 Mon Sep 17 00:00:00 2001 From: Ruben Niculcea Date: Mon, 8 Jun 2015 02:08:10 -0700 Subject: [PATCH 2/3] Remove unused display link --- React/Base/RCTBridge.m | 7 ------- 1 file changed, 7 deletions(-) diff --git a/React/Base/RCTBridge.m b/React/Base/RCTBridge.m index 6d093ee36aa6f1..566976ecd3b1b8 100644 --- a/React/Base/RCTBridge.m +++ b/React/Base/RCTBridge.m @@ -1088,13 +1088,6 @@ - (void)initJS object:_parentBridge userInfo:userInfo]; - /** - * Register the display link to start sending js calls after everything - * is setup - */ - NSRunLoop *targetRunLoop = [_javaScriptExecutor isKindOfClass:[RCTContextExecutor class]] ? [NSRunLoop currentRunLoop] : [NSRunLoop mainRunLoop]; - [_jsDisplayLink addToRunLoop:targetRunLoop forMode:NSRunLoopCommonModes]; - [[NSNotificationCenter defaultCenter] postNotificationName:RCTJavaScriptDidLoadNotification object:_parentBridge userInfo:@{ @"bridge": self }]; From 7b0a02b33b89ffb09a93c3918967a6c53003179c Mon Sep 17 00:00:00 2001 From: Ruben Niculcea Date: Fri, 12 Jun 2015 09:34:37 -0700 Subject: [PATCH 3/3] Use RCTJavaScriptDidFailToLoadNotification to reload JS on compile errors --- React/Base/RCTBridge.m | 4 ---- React/Base/RCTDevMenu.m | 5 +++++ 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/React/Base/RCTBridge.m b/React/Base/RCTBridge.m index 566976ecd3b1b8..6802df849273c8 100644 --- a/React/Base/RCTBridge.m +++ b/React/Base/RCTBridge.m @@ -1087,10 +1087,6 @@ - (void)initJS [[NSNotificationCenter defaultCenter] postNotificationName:RCTJavaScriptDidFailToLoadNotification object:_parentBridge userInfo:userInfo]; - - [[NSNotificationCenter defaultCenter] postNotificationName:RCTJavaScriptDidLoadNotification - object:_parentBridge - userInfo:@{ @"bridge": self }]; } else { diff --git a/React/Base/RCTDevMenu.m b/React/Base/RCTDevMenu.m index 8a5f23f9d2f256..7574b0dcdeeef6 100644 --- a/React/Base/RCTDevMenu.m +++ b/React/Base/RCTDevMenu.m @@ -115,6 +115,11 @@ - (instancetype)init selector:@selector(jsLoaded:) name:RCTJavaScriptDidLoadNotification object:nil]; + + [notificationCenter addObserver:self + selector:@selector(jsLoaded:) + name:RCTJavaScriptDidFailToLoadNotification + object:nil]; _defaults = [NSUserDefaults standardUserDefaults]; _settings = [[NSMutableDictionary alloc] init];