Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 1 addition & 30 deletions packages/react-native/React/CoreModules/RCTDevSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,6 @@
#import <React/RCTEventEmitter.h>
#import <React/RCTInitializing.h>

@class RCTPackagerClientResponder;
typedef uint32_t RCTHandlerToken;
typedef void (^RCTNotificationHandler)(NSDictionary<NSString *, id> *);
typedef void (^RCTRequestHandler)(NSDictionary<NSString *, id> *, RCTPackagerClientResponder *);
typedef void (^RCTConnectedHandler)(void);

@class RCTPackagerConnection;

@protocol RCTPackagerClientMethod;
Expand Down Expand Up @@ -114,30 +108,7 @@ typedef void (^RCTConnectedHandler)(void);

#if RCT_DEV_MENU
- (void)addHandler:(id<RCTPackagerClientMethod>)handler
forPackagerMethod:(NSString *)name __deprecated_msg("Use addRequestHandler or addNotificationHandler instead");
#endif

#if RCT_DEV
/**
* Registers a handler for a notification broadcast from the packager. An
* example is "reload" - an instruction to reload from the packager.
* If multiple notification handlers are registered for the same method, they
* will all be invoked sequentially.
*/
- (RCTHandlerToken)addNotificationHandler:(RCTNotificationHandler)handler
queue:(dispatch_queue_t)queue
forMethod:(NSString *)method;

/**
* Registers a handler for a request from the packager. An example is
* pokeSamplingProfiler; it asks for profile data from the client.
* Only one handler can be registered for a given method; calling this
* displaces any previous request handler registered for that method.
*/
- (RCTHandlerToken)addRequestHandler:(RCTRequestHandler)handler
queue:(dispatch_queue_t)queue
forMethod:(NSString *)method;

forPackagerMethod:(NSString *)name __deprecated_msg("Use RCTPackagerConnection directly instead");
#endif

@end
Expand Down
29 changes: 4 additions & 25 deletions packages/react-native/React/CoreModules/RCTDevSettings.mm
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void RCTDevSettingsSetEnabled(BOOL enabled)
devSettingsMenuEnabled = enabled;
}

#if RCT_DEV || RCT_REMOTE_PROFILE
#if RCT_DEV_MENU || RCT_REMOTE_PROFILE

@interface RCTDevSettingsUserDefaultsDataSource : NSObject <RCTDevSettingsDataSource>

Expand Down Expand Up @@ -190,15 +190,15 @@ - (void)initialize

#if RCT_DEV_SETTINGS_ENABLE_PACKAGER_CONNECTION
if (numInitializedModules++ == 0) {
reloadToken = [self
reloadToken = [_packagerConnection
addNotificationHandler:^(id params) {
RCTTriggerReloadCommandListeners(@"Global hotkey");
}
queue:dispatch_get_main_queue()
forMethod:@"reload"];
#if RCT_DEV_MENU
__weak __typeof(self) weakSelf = self;
devMenuToken = [self
devMenuToken = [_packagerConnection
addNotificationHandler:^(id params) {
__typeof(self) strongSelf = weakSelf;
if (strongSelf == nullptr) {
Expand Down Expand Up @@ -437,23 +437,6 @@ - (void)setExecutorClass:(Class)executorClass
}
}

#if RCT_DEV
- (RCTHandlerToken)addNotificationHandler:(RCTNotificationHandler)handler
queue:(dispatch_queue_t)queue
forMethod:(NSString *)method
{
return [_packagerConnection addNotificationHandler:handler queue:queue forMethod:method];
}

- (RCTHandlerToken)addRequestHandler:(RCTRequestHandler)handler
queue:(dispatch_queue_t)queue
forMethod:(NSString *)method
{
return [_packagerConnection addRequestHandler:handler queue:queue forMethod:method];
}

#endif

- (void)addHandler:(id<RCTPackagerClientMethod>)handler forPackagerMethod:(NSString *)name
{
#if RCT_DEV_SETTINGS_ENABLE_PACKAGER_CONNECTION
Expand Down Expand Up @@ -544,7 +527,7 @@ - (void)jsLoaded:(NSNotification *)notification

@end

#else // #if RCT_DEV || RCT_REMOTE_PROFILE
#else // #if RCT_DEV_MENU

@interface RCTDevSettings () <NativeDevSettingsSpec>
@end
Expand Down Expand Up @@ -610,10 +593,6 @@ - (void)setIsShakeToShowDevMenuEnabled:(BOOL)enabled
return std::make_shared<facebook::react::NativeDevSettingsSpecJSI>(params);
}

- (void)addHandler:(id<RCTPackagerClientMethod>)handler forPackagerMethod:(NSString *)name
{
}

@end

#endif // #if RCT_DEV_MENU
Expand Down