From ba9ef00ab96b8910d271cbeef28a67e9368263d9 Mon Sep 17 00:00:00 2001 From: James Ide Date: Wed, 13 May 2015 08:25:00 -0700 Subject: [PATCH] [RCTBridge] Clean up reload notification observer Summary: After the RCTBatchedBridge refactor, the `-[NSNotificationCenter addObserver]` and `[removeObserver]` calls got divided between RCTBridge and RCTBatchedBridge. This diff does two things: - Moved `removeObserver` out of RTCBatchedBridge and into `-[RCTBridge invalidate]` - Moved `addObserver` from `bindKeys` to `setUp`. This is so that `-[RCTBridge reload]` will re-add the observer after invalidating and removing the observer cc @tadeuzagallo Closes https://github.com/facebook/react-native/pull/1212 Github Author: James Ide Test Plan: Imported from GitHub, without a `Test Plan:` line. --- React/Base/RCTBridge.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/React/Base/RCTBridge.m b/React/Base/RCTBridge.m index 9cfa969cf..7e21a44c2 100644 --- a/React/Base/RCTBridge.m +++ b/React/Base/RCTBridge.m @@ -789,6 +789,7 @@ static id _latestJSExecutor; * This runs only on the main thread, but crashes the subclass * RCTAssertMainThread(); */ + [[NSNotificationCenter defaultCenter] removeObserver:self]; [self invalidate]; } @@ -1174,7 +1175,6 @@ RCT_INNER_BRIDGE_ONLY(_invokeAndProcessModule:(NSString *)module method:(NSStrin void (^mainThreadInvalidate)(void) = ^{ - [[NSNotificationCenter defaultCenter] removeObserver:self]; [_mainDisplayLink invalidate]; _mainDisplayLink = nil;