[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 <ide@jameside.com>

Test Plan: Imported from GitHub, without a `Test Plan:` line.
This commit is contained in:
James Ide
2015-05-13 08:25:00 -07:00
committed by Christopher Chedeau
parent a0440daf98
commit ba9ef00ab9

View File

@@ -789,6 +789,7 @@ static id<RCTJavaScriptExecutor> _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;