From 8fe04cfd7e54b4dc98b788823dcaf4afc415c697 Mon Sep 17 00:00:00 2001 From: Peter Argany Date: Fri, 17 Jan 2020 17:20:13 -0800 Subject: [PATCH] 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 --- React/CoreModules/RCTDevSettings.mm | 30 +++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/React/CoreModules/RCTDevSettings.mm b/React/CoreModules/RCTDevSettings.mm index 08615d6131a..8cb40a963a8 100644 --- a/React/CoreModules/RCTDevSettings.mm +++ b/React/CoreModules/RCTDevSettings.mm @@ -113,7 +113,7 @@ void RCTDevSettingsSetEnabled(BOOL enabled) { @end -@interface RCTDevSettings () { +@interface RCTDevSettings () { BOOL _isJSLoaded; #if ENABLE_PACKAGER_CONNECTION RCTHandlerToken _reloadToken; @@ -129,14 +129,9 @@ void RCTDevSettingsSetEnabled(BOOL enabled) { RCT_EXPORT_MODULE() -+ (BOOL)requiresMainQueueSetup -{ - return YES; // RCT_DEV-only -} - - (instancetype)init { - // default behavior is to use NSUserDefaults + // Default behavior is to use NSUserDefaults with shake and hot loading enabled. NSDictionary *defaultValues = @{ kRCTDevSettingShakeToShowDevMenu : @YES, kRCTDevSettingHotLoadingEnabled : @YES, @@ -177,11 +172,9 @@ RCT_EXPORT_MODULE() #endif #if RCT_ENABLE_INSPECTOR - // we need this dispatch back to the main thread because even though this - // is executed on the main thread, at this point the bridge is not yet - // finished with its initialisation. But it does finish by the time it - // relinquishes control of the main thread, so only queue on the JS thread - // after the current main thread operation is done. + // We need this dispatch to the main thread because the bridge is not yet + // finished with its initialisation. By the time it relinquishes control of + // the main thread, this operation can be performed. dispatch_async(dispatch_get_main_queue(), ^{ [bridge dispatchBlock:^{ @@ -439,10 +432,18 @@ RCT_EXPORT_METHOD(addMenuItem:(NSString *)title) }); } +- (std::shared_ptr)getTurboModuleWithJsInvoker:(std::shared_ptr)jsInvoker +{ + return std::make_shared(self, jsInvoker); +} + @end #else // #if RCT_DEV +@interface RCTDevSettings () +@end + @implementation RCTDevSettings - (instancetype)initWithDataSource:(id)dataSource @@ -489,6 +490,11 @@ RCT_EXPORT_METHOD(addMenuItem:(NSString *)title) { } +- (std::shared_ptr)getTurboModuleWithJsInvoker:(std::shared_ptr)jsInvoker +{ + return std::make_shared(self, jsInvoker); +} + @end #endif