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:
Родитель
2ccc8fbc28
Коммит
549cac63cb
|
@ -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);
|
||||
|
|
Загрузка…
Ссылка в новой задаче