Skip to content

Commit 549cac6

Browse files
rickhanloniifacebook-github-bot
authored andcommitted
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
1 parent 2ccc8fb commit 549cac6

File tree

5 files changed

+23
-2
lines changed

5 files changed

+23
-2
lines changed

Libraries/FBReactNativeSpec/FBReactNativeSpec/FBReactNativeSpec-generated.mm

+7
Original file line numberDiff line numberDiff line change
@@ -785,6 +785,10 @@ + (RCTManagedPointer *)JS_NativeAsyncStorage_SpecGetAllKeysCallbackError:(id)jso
785785
return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, VoidKind, "reload", @selector(reload), args, count);
786786
}
787787

788+
static facebook::jsi::Value __hostFunction_NativeDevSettingsSpecJSI_reloadWithReason(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
789+
return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, VoidKind, "reloadWithReason", @selector(reloadWithReason:), args, count);
790+
}
791+
788792
static facebook::jsi::Value __hostFunction_NativeDevSettingsSpecJSI_setHotLoadingEnabled(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
789793
return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, VoidKind, "setHotLoadingEnabled", @selector(setHotLoadingEnabled:), args, count);
790794
}
@@ -816,6 +820,9 @@ + (RCTManagedPointer *)JS_NativeAsyncStorage_SpecGetAllKeysCallbackError:(id)jso
816820
methodMap_["reload"] = MethodMetadata {0, __hostFunction_NativeDevSettingsSpecJSI_reload};
817821

818822

823+
methodMap_["reloadWithReason"] = MethodMetadata {1, __hostFunction_NativeDevSettingsSpecJSI_reloadWithReason};
824+
825+
819826
methodMap_["setHotLoadingEnabled"] = MethodMetadata {1, __hostFunction_NativeDevSettingsSpecJSI_setHotLoadingEnabled};
820827

821828

Libraries/FBReactNativeSpec/FBReactNativeSpec/FBReactNativeSpec.h

+1
Original file line numberDiff line numberDiff line change
@@ -739,6 +739,7 @@ namespace facebook {
739739
@protocol NativeDevSettingsSpec <RCTBridgeModule, RCTTurboModule>
740740

741741
- (void)reload;
742+
- (void)reloadWithReason:(NSString *)reason;
742743
- (void)setHotLoadingEnabled:(BOOL)isHotLoadingEnabled;
743744
- (void)setIsDebuggingRemotely:(BOOL)isDebuggingRemotelyEnabled;
744745
- (void)setProfilingEnabled:(BOOL)isProfilingEnabled;

Libraries/NativeModules/specs/NativeDevSettings.js

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import * as TurboModuleRegistry from '../../TurboModule/TurboModuleRegistry';
1515

1616
export interface Spec extends TurboModule {
1717
+reload: () => void;
18+
+reloadWithReason?: (reason: string) => void;
1819
+setHotLoadingEnabled: (isHotLoadingEnabled: boolean) => void;
1920
+setIsDebuggingRemotely: (isDebuggingRemotelyEnabled: boolean) => void;
2021
+setProfilingEnabled: (isProfilingEnabled: boolean) => void;

Libraries/Utilities/DevSettings.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
/**
22
* Copyright (c) Facebook, Inc. and its affiliates.
33
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
47
* @format
58
*/
69

@@ -36,8 +39,12 @@ class DevSettings extends NativeEventEmitter {
3639
});
3740
}
3841

39-
reload() {
40-
NativeDevSettings.reload();
42+
reload(reason: string) {
43+
if (typeof NativeDevSettings.reloadWithReason === 'function') {
44+
NativeDevSettings.reloadWithReason(reason || 'Uncategorized from JS');
45+
} else {
46+
NativeDevSettings.reload();
47+
}
4148
}
4249

4350
// TODO: Add other dev setting methods exposed by the native module.

ReactAndroid/src/main/java/com/facebook/react/modules/debug/DevSettingsModule.java

+5
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ public void run() {
5252
}
5353
}
5454

55+
@ReactMethod
56+
public void reloadWithReason(String reason) {
57+
this.reload();
58+
}
59+
5560
@ReactMethod
5661
public void setHotLoadingEnabled(boolean isHotLoadingEnabled) {
5762
mDevSupportManager.setHotModuleReplacementEnabled(isHotLoadingEnabled);

0 commit comments

Comments
 (0)