Introducing `RCTBridgeWillBeInvalidatedNotification`
Summary: This diff introduces a new broadcasting event for Bridge that communicates that the bridge is being invalidated. This notification can be used by interested parties as a signal to start tearing down all bridge-dependant processes. The biggest difference between the new event and `RCTBridgeWillInvalidateModulesNotification` is that the latter is being called asynchronously on the JavaScript thread, whereas the new one is being called on whatever thread caused the Bridge invalidation (deallocation) *synchronously*. In most cases that happens on the main thread that allows destroying strictly-main-threaded infra (mostly UI) synchronously and avoids races. Changelog: [Internal] Reviewed By: sammy-SC Differential Revision: D18050889 fbshipit-source-id: 9364c820ea2b0358edf45f0e2b3e16a13d730a9c
This commit is contained in:
Родитель
b3cb27ee9f
Коммит
7a20964e9d
|
@ -102,13 +102,19 @@ RCT_EXTERN NSString *const RCTBridgeWillInvalidateModulesNotification;
|
|||
*/
|
||||
RCT_EXTERN NSString *const RCTBridgeDidInvalidateModulesNotification;
|
||||
|
||||
/**
|
||||
* This notification fires right before the bridge starting invalidation process.
|
||||
* Handle this notification to perform additional invalidation.
|
||||
* The notification can be issued on any thread.
|
||||
*/
|
||||
RCT_EXTERN NSString *const RCTBridgeWillBeInvalidatedNotification;
|
||||
|
||||
/**
|
||||
* Key for the RCTSource object in the RCTBridgeDidDownloadScriptNotification
|
||||
* userInfo dictionary.
|
||||
*/
|
||||
RCT_EXTERN NSString *const RCTBridgeDidDownloadScriptNotificationSourceKey;
|
||||
|
||||
|
||||
/**
|
||||
* Key for the reload reason in the RCTBridgeWillReloadNotification userInfo dictionary.
|
||||
*/
|
||||
|
|
|
@ -36,6 +36,7 @@ NSString *const RCTBridgeWillDownloadScriptNotification = @"RCTBridgeWillDownloa
|
|||
NSString *const RCTBridgeDidDownloadScriptNotification = @"RCTBridgeDidDownloadScriptNotification";
|
||||
NSString *const RCTBridgeWillInvalidateModulesNotification = @"RCTBridgeWillInvalidateModulesNotification";
|
||||
NSString *const RCTBridgeDidInvalidateModulesNotification = @"RCTBridgeDidInvalidateModulesNotification";
|
||||
NSString *const RCTBridgeWillBeInvalidatedNotification = @"RCTBridgeWillBeInvalidatedNotification";
|
||||
NSString *const RCTBridgeDidDownloadScriptNotificationSourceKey = @"source";
|
||||
NSString *const RCTBridgeDidDownloadScriptNotificationReasonKey = @"reason";
|
||||
NSString *const RCTBridgeDidDownloadScriptNotificationBridgeDescriptionKey = @"bridgeDescription";
|
||||
|
@ -386,6 +387,9 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init)
|
|||
|
||||
- (void)invalidate
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:RCTBridgeWillBeInvalidatedNotification
|
||||
object:self];
|
||||
|
||||
RCTBridge *batchedBridge = self.batchedBridge;
|
||||
self.batchedBridge = nil;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче