Migrate RCTDevSettings to TM

Summary: As titled. The work to write the spec and make this module compatible were done in D18148890.

Reviewed By: RSNara

Differential Revision: D19442016

fbshipit-source-id: 369bb4247d6590d41ec414f93c79d98d4a6bed88
This commit is contained in:
Peter Argany
2020-01-17 17:22:14 -08:00
committed by Facebook Github Bot
parent e69ce88ef6
commit 8fe04cfd7e
+18 -12
View File
@@ -113,7 +113,7 @@ void RCTDevSettingsSetEnabled(BOOL enabled) {
@end @end
@interface RCTDevSettings () <RCTBridgeModule, RCTInvalidating> { @interface RCTDevSettings () <RCTBridgeModule, RCTInvalidating, NativeDevSettingsSpec> {
BOOL _isJSLoaded; BOOL _isJSLoaded;
#if ENABLE_PACKAGER_CONNECTION #if ENABLE_PACKAGER_CONNECTION
RCTHandlerToken _reloadToken; RCTHandlerToken _reloadToken;
@@ -129,14 +129,9 @@ void RCTDevSettingsSetEnabled(BOOL enabled) {
RCT_EXPORT_MODULE() RCT_EXPORT_MODULE()
+ (BOOL)requiresMainQueueSetup
{
return YES; // RCT_DEV-only
}
- (instancetype)init - (instancetype)init
{ {
// default behavior is to use NSUserDefaults // Default behavior is to use NSUserDefaults with shake and hot loading enabled.
NSDictionary *defaultValues = @{ NSDictionary *defaultValues = @{
kRCTDevSettingShakeToShowDevMenu : @YES, kRCTDevSettingShakeToShowDevMenu : @YES,
kRCTDevSettingHotLoadingEnabled : @YES, kRCTDevSettingHotLoadingEnabled : @YES,
@@ -177,11 +172,9 @@ RCT_EXPORT_MODULE()
#endif #endif
#if RCT_ENABLE_INSPECTOR #if RCT_ENABLE_INSPECTOR
// we need this dispatch back to the main thread because even though this // We need this dispatch to the main thread because the bridge is not yet
// is executed on the main thread, at this point the bridge is not yet // finished with its initialisation. By the time it relinquishes control of
// finished with its initialisation. But it does finish by the time it // the main thread, this operation can be performed.
// relinquishes control of the main thread, so only queue on the JS thread
// after the current main thread operation is done.
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
[bridge [bridge
dispatchBlock:^{ dispatchBlock:^{
@@ -439,10 +432,18 @@ RCT_EXPORT_METHOD(addMenuItem:(NSString *)title)
}); });
} }
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModuleWithJsInvoker:(std::shared_ptr<facebook::react::CallInvoker>)jsInvoker
{
return std::make_shared<facebook::react::NativeDevSettingsSpecJSI>(self, jsInvoker);
}
@end @end
#else // #if RCT_DEV #else // #if RCT_DEV
@interface RCTDevSettings () <NativeDevSettingsSpec>
@end
@implementation RCTDevSettings @implementation RCTDevSettings
- (instancetype)initWithDataSource:(id<RCTDevSettingsDataSource>)dataSource - (instancetype)initWithDataSource:(id<RCTDevSettingsDataSource>)dataSource
@@ -489,6 +490,11 @@ RCT_EXPORT_METHOD(addMenuItem:(NSString *)title)
{ {
} }
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModuleWithJsInvoker:(std::shared_ptr<facebook::react::CallInvoker>)jsInvoker
{
return std::make_shared<facebook::react::NativeDevSettingsSpecJSI>(self, jsInvoker);
}
@end @end
#endif #endif