Skip to content
Permalink
Browse files
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
  • Loading branch information
rickhanlonii authored and facebook-github-bot committed Sep 30, 2019
1 parent 2ccc8fb commit 549cac63cb252037f73453c5d4e7ae5f15586607
Showing 5 changed files with 23 additions and 2 deletions.
@@ -785,6 +785,10 @@ + (RCTManagedPointer *)JS_NativeAsyncStorage_SpecGetAllKeysCallbackError:(id)jso
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 @@ + (RCTManagedPointer *)JS_NativeAsyncStorage_SpecGetAllKeysCallbackError:(id)jso
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 void run() {
}
}

@ReactMethod
public void reloadWithReason(String reason) {
this.reload();
}

@ReactMethod
public void setHotLoadingEnabled(boolean isHotLoadingEnabled) {
mDevSupportManager.setHotModuleReplacementEnabled(isHotLoadingEnabled);

0 comments on commit 549cac6

Please sign in to comment.