Broadcast TurboModule creation
Summary: When TurboModules are created, we need to broadcast this event using `NSNotificationCenter`. This is important because a number of TurboModules/ObjC classes listen to this notification and perform side effects. I found these using https://fburl.com/codesearch/j0a9p3dr. - FBReactKitServerSnapshotTests: After the RCTExceptionsManager is initialized, it assigns itself as the delegate to the RCTExceptionsManager instance. - FBProfilePictureUploadFlowController: After FBProfileFrameNativeModule is initialized, it calls `[module setFlowController: self]` - RCTFBSession: After every NativeModule is initialized, if that NativeModule conforms to the RCTFBSessionModule protocol, assign the session to it. - TwilightLocalMedia: Hack to figure out when the bridge is initialized. - FBMarketplaceMenuItemHandler: After FBMarketplaceNativeModule is initialized, attach a data source obtained from the session to the module. Then, attach module to data source. - RCTModuleInitTests: Set local state based on if certain modules are initialized (https://fburl.com/e34kezb5). - IGReactModule: When the RCTImageLoader is initialized, set it's image cache to `[IGReactImageCache new]`. - RCTIGUserSession: Like RCTFBSession - FBReactModuleTracker: This keeps a list of all dispatched notifications (for some reason). - RCTModuleInitNotificationRaceTests: Sets self.didDetectViewManagerInit to true if RCTTestViewManager is initialized. Reviewed By: fkgozali Differential Revision: D14281557 fbshipit-source-id: 9fcf1bb5f5650fcc3a3e50c6d93405b0b618e271
This commit is contained in:
Родитель
29613a0364
Коммит
8ad695b10e
|
@ -9,6 +9,7 @@
|
|||
|
||||
#import <cassert>
|
||||
|
||||
#import <React/RCTBridge+Private.h>
|
||||
#import <React/RCTBridgeModule.h>
|
||||
#import <React/RCTCxxModule.h>
|
||||
#import <React/RCTLog.h>
|
||||
|
@ -230,6 +231,16 @@ static Class getFallbackClassFromName(const char *name) {
|
|||
}
|
||||
|
||||
_rctTurboModuleCache.insert({moduleName, module});
|
||||
|
||||
/**
|
||||
* Broadcast that this TurboModule was created.
|
||||
*
|
||||
* TODO(T41180176): Investigate whether we can get rid of this after all
|
||||
* TurboModules are rolled out
|
||||
*/
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:RCTDidInitializeModuleNotification
|
||||
object:_bridge.parentBridge
|
||||
userInfo:@{@"module": module, @"bridge": RCTNullIfNil(_bridge.parentBridge)}];
|
||||
return module;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче