Skip to content

Commit

Permalink
Basic bridgeless support for RCTDevMenu
Browse files Browse the repository at this point in the history
Summary:
Changelog: [Internal]

This removes a couple dependencies on bridge in dev menu native module. So far reloading works, will get inspector and other options working in follow ups.

Reviewed By: sammy-SC

Differential Revision: D26240391

fbshipit-source-id: 7c9d585f4efa6cc9db995ef8a33865831bc8d526
  • Loading branch information
Peter Argany authored and facebook-github-bot committed Feb 4, 2021
1 parent ac63d57 commit 6774358
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions React/CoreModules/RCTDevMenu.mm
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#import <React/RCTBundleURLProvider.h>
#import <React/RCTDefines.h>
#import <React/RCTDevSettings.h>
#import <React/RCTJSInvokerModule.h>
#import <React/RCTKeyCommands.h>
#import <React/RCTLog.h>
#import <React/RCTReloadCommand.h>
Expand Down Expand Up @@ -85,7 +86,7 @@ - (NSString *)title

typedef void (^RCTDevMenuAlertActionHandler)(UIAlertAction *action);

@interface RCTDevMenu () <RCTBridgeModule, RCTInvalidating, NativeDevMenuSpec>
@interface RCTDevMenu () <RCTBridgeModule, RCTInvalidating, NativeDevMenuSpec, RCTJSInvokerModule>

@end

Expand All @@ -96,6 +97,7 @@ @implementation RCTDevMenu {

@synthesize bridge = _bridge;
@synthesize moduleRegistry = _moduleRegistry;
@synthesize invokeJS = _invokeJS;

RCT_EXPORT_MODULE()

Expand Down Expand Up @@ -387,7 +389,7 @@ - (void)setDefaultJSBundle

RCT_EXPORT_METHOD(show)
{
if (_actionSheet || !_bridge || RCTRunningInAppExtension()) {
if (_actionSheet || RCTRunningInAppExtension()) {
return;
}

Expand Down Expand Up @@ -417,7 +419,11 @@ - (void)setDefaultJSBundle
_presentedItems = items;
[RCTPresentedViewController() presentViewController:_actionSheet animated:YES completion:nil];

[_bridge enqueueJSCall:@"RCTNativeAppEventEmitter" method:@"emit" args:@[ @"RCTDevMenuShown" ] completion:NULL];
if (_bridge) {
[_bridge enqueueJSCall:@"RCTNativeAppEventEmitter" method:@"emit" args:@[ @"RCTDevMenuShown" ] completion:NULL];
} else {
_invokeJS(@"RCTNativeAppEventEmitter", @"emit", @[ @"RCTDevMenuShown" ]);
}
}

- (RCTDevMenuAlertActionHandler)alertActionHandlerForDevItem:(RCTDevMenuItem *__nullable)item
Expand Down

0 comments on commit 6774358

Please sign in to comment.