Add reloadWithReason to DevSettings

Summary:
This diff adds reloadWithReason to the NativeDevSettings and updates the exposed DevSettings.reload method to send to it if it's available (setting an 'uncategorized' reason if one isn't set.

[General][Feature] Update DevSettings.reload to accept a reason

Reviewed By: RSNara

Differential Revision: D17499343

fbshipit-source-id: e8c9724800f93d3b9a5d2a8fe9f689d51947d39b
This commit is contained in:
Rick Hanlon 2019-09-30 07:01:15 -07:00 коммит произвёл Facebook Github Bot
Родитель 2ccc8fbc28
Коммит 549cac63cb
5 изменённых файлов: 23 добавлений и 2 удалений

Просмотреть файл

@ -785,6 +785,10 @@ namespace facebook {
return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, VoidKind, "reload", @selector(reload), args, count);
}
static facebook::jsi::Value __hostFunction_NativeDevSettingsSpecJSI_reloadWithReason(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, VoidKind, "reloadWithReason", @selector(reloadWithReason:), args, count);
}
static facebook::jsi::Value __hostFunction_NativeDevSettingsSpecJSI_setHotLoadingEnabled(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, VoidKind, "setHotLoadingEnabled", @selector(setHotLoadingEnabled:), args, count);
}
@ -816,6 +820,9 @@ namespace facebook {
methodMap_["reload"] = MethodMetadata {0, __hostFunction_NativeDevSettingsSpecJSI_reload};
methodMap_["reloadWithReason"] = MethodMetadata {1, __hostFunction_NativeDevSettingsSpecJSI_reloadWithReason};
methodMap_["setHotLoadingEnabled"] = MethodMetadata {1, __hostFunction_NativeDevSettingsSpecJSI_setHotLoadingEnabled};

Просмотреть файл

@ -739,6 +739,7 @@ namespace facebook {
@protocol NativeDevSettingsSpec <RCTBridgeModule, RCTTurboModule>
- (void)reload;
- (void)reloadWithReason:(NSString *)reason;
- (void)setHotLoadingEnabled:(BOOL)isHotLoadingEnabled;
- (void)setIsDebuggingRemotely:(BOOL)isDebuggingRemotelyEnabled;
- (void)setProfilingEnabled:(BOOL)isProfilingEnabled;

Просмотреть файл

@ -15,6 +15,7 @@ import * as TurboModuleRegistry from '../../TurboModule/TurboModuleRegistry';
export interface Spec extends TurboModule {
+reload: () => void;
+reloadWithReason?: (reason: string) => void;
+setHotLoadingEnabled: (isHotLoadingEnabled: boolean) => void;
+setIsDebuggingRemotely: (isDebuggingRemotelyEnabled: boolean) => void;
+setProfilingEnabled: (isProfilingEnabled: boolean) => void;

Просмотреть файл

@ -1,6 +1,9 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/
@ -36,8 +39,12 @@ class DevSettings extends NativeEventEmitter {
});
}
reload() {
NativeDevSettings.reload();
reload(reason: string) {
if (typeof NativeDevSettings.reloadWithReason === 'function') {
NativeDevSettings.reloadWithReason(reason || 'Uncategorized from JS');
} else {
NativeDevSettings.reload();
}
}
// TODO: Add other dev setting methods exposed by the native module.

Просмотреть файл

@ -52,6 +52,11 @@ public class DevSettingsModule extends ReactContextBaseJavaModule {
}
}
@ReactMethod
public void reloadWithReason(String reason) {
this.reload();
}
@ReactMethod
public void setHotLoadingEnabled(boolean isHotLoadingEnabled) {
mDevSupportManager.setHotModuleReplacementEnabled(isHotLoadingEnabled);