Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 8aa8524

Browse files
RSNarafacebook-github-bot
authored andcommittedMay 21, 2021
Migrate RCTDevSettings to initialize
Summary: Changelog: [Internal] Reviewed By: fkgozali Differential Revision: D28595955 fbshipit-source-id: e61c2d321826eafb60fdac820b76d0f7d100796a
1 parent ed86891 commit 8aa8524

File tree

2 files changed

+22
-23
lines changed

2 files changed

+22
-23
lines changed
 

‎React/CoreModules/RCTDevSettings.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#import <React/RCTBridge.h>
99
#import <React/RCTDefines.h>
1010
#import <React/RCTEventEmitter.h>
11+
#import <React/RCTInitializing.h>
1112

1213
@protocol RCTPackagerClientMethod;
1314

@@ -40,7 +41,7 @@
4041

4142
@end
4243

43-
@interface RCTDevSettings : RCTEventEmitter
44+
@interface RCTDevSettings : RCTEventEmitter <RCTInitializing>
4445

4546
- (instancetype)initWithDataSource:(id<RCTDevSettingsDataSource>)dataSource;
4647

‎React/CoreModules/RCTDevSettings.mm

+20-22
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,22 @@ - (instancetype)initWithDataSource:(id<RCTDevSettingsDataSource>)dataSource
166166
return self;
167167
}
168168

169-
- (void)setBundleManager:(RCTBundleManager *)bundleManager
169+
- (void)initialize
170170
{
171-
_bundleManager = bundleManager;
171+
#if ENABLE_PACKAGER_CONNECTION
172+
if (self.bridge) {
173+
RCTBridge *__weak weakBridge = self.bridge;
174+
_reloadToken = [[RCTPackagerConnection sharedPackagerConnection]
175+
addNotificationHandler:^(id params) {
176+
if (params != (id)kCFNull && [params[@"debug"] boolValue]) {
177+
weakBridge.executorClass = objc_lookUpClass("RCTWebSocketExecutor");
178+
}
179+
RCTTriggerReloadCommandListeners(@"Global hotkey");
180+
}
181+
queue:dispatch_get_main_queue()
182+
forMethod:@"reload"];
183+
}
184+
#endif
172185

173186
#if RCT_ENABLE_INSPECTOR
174187
if (self.bridge) {
@@ -178,12 +191,12 @@ - (void)setBundleManager:(RCTBundleManager *)bundleManager
178191
dispatch_async(dispatch_get_main_queue(), ^{
179192
[self.bridge
180193
dispatchBlock:^{
181-
[RCTInspectorDevServerHelper connectWithBundleURL:bundleManager.bundleURL];
194+
[RCTInspectorDevServerHelper connectWithBundleURL:self.bundleManager.bundleURL];
182195
}
183196
queue:RCTJSThread];
184197
});
185198
} else {
186-
[RCTInspectorDevServerHelper connectWithBundleURL:bundleManager.bundleURL];
199+
[RCTInspectorDevServerHelper connectWithBundleURL:self.bundleManager.bundleURL];
187200
}
188201
#endif
189202

@@ -192,24 +205,6 @@ - (void)setBundleManager:(RCTBundleManager *)bundleManager
192205
});
193206
}
194207

195-
- (void)setBridge:(RCTBridge *)bridge
196-
{
197-
[super setBridge:bridge];
198-
199-
#if ENABLE_PACKAGER_CONNECTION
200-
RCTBridge *__weak weakBridge = bridge;
201-
_reloadToken = [[RCTPackagerConnection sharedPackagerConnection]
202-
addNotificationHandler:^(id params) {
203-
if (params != (id)kCFNull && [params[@"debug"] boolValue]) {
204-
weakBridge.executorClass = objc_lookUpClass("RCTWebSocketExecutor");
205-
}
206-
RCTTriggerReloadCommandListeners(@"Global hotkey");
207-
}
208-
queue:dispatch_get_main_queue()
209-
forMethod:@"reload"];
210-
#endif
211-
}
212-
213208
- (dispatch_queue_t)methodQueue
214209
{
215210
return dispatch_get_main_queue();
@@ -512,6 +507,9 @@ - (instancetype)initWithDataSource:(id<RCTDevSettingsDataSource>)dataSource
512507
{
513508
return [super init];
514509
}
510+
- (void)initialize
511+
{
512+
}
515513
- (BOOL)isHotLoadingAvailable
516514
{
517515
return NO;

0 commit comments

Comments
 (0)
Please sign in to comment.