Add missing NativeEventListener methods to NativeDevSettings (#27838)

Summary:
Since migrating to Turbomodules (8fe04cf) the addMenuItem method crashes because the NativeEventListener methods are missing from the codegen flow type. Added the same methods based on what we do in AppState which is another native module that extends NativeEventListener.

## Changelog

[Internal] [Fixed] - Add missing NativeEventListener methods to NativeDevSettings
Pull Request resolved: https://github.com/facebook/react-native/pull/27838

Test Plan:
|Before|After|
|{F226978596}|{F226978628}

Differential Revision: D19518474

Pulled By: PeteTheHeat

fbshipit-source-id: acddba9f18dd558df1d6df78b539689fdfd0062f
This commit is contained in:
Janic Duplessis
2020-01-23 13:20:53 -08:00
committed by Facebook Github Bot
parent e6f3388541
commit d72e078df4
5 changed files with 36 additions and 0 deletions
@@ -931,6 +931,14 @@ namespace facebook {
return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, VoidKind, "addMenuItem", @selector(addMenuItem:), args, count);
}
static facebook::jsi::Value __hostFunction_NativeDevSettingsSpecJSI_addListener(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, VoidKind, "addListener", @selector(addListener:), args, count);
}
static facebook::jsi::Value __hostFunction_NativeDevSettingsSpecJSI_removeListeners(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, VoidKind, "removeListeners", @selector(removeListeners:), args, count);
}
static facebook::jsi::Value __hostFunction_NativeDevSettingsSpecJSI_setIsShakeToShowDevMenuEnabled(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, VoidKind, "setIsShakeToShowDevMenuEnabled", @selector(setIsShakeToShowDevMenuEnabled:), args, count);
}
@@ -963,6 +971,12 @@ namespace facebook {
methodMap_["addMenuItem"] = MethodMetadata {1, __hostFunction_NativeDevSettingsSpecJSI_addMenuItem};
methodMap_["addListener"] = MethodMetadata {1, __hostFunction_NativeDevSettingsSpecJSI_addListener};
methodMap_["removeListeners"] = MethodMetadata {1, __hostFunction_NativeDevSettingsSpecJSI_removeListeners};
methodMap_["setIsShakeToShowDevMenuEnabled"] = MethodMetadata {1, __hostFunction_NativeDevSettingsSpecJSI_setIsShakeToShowDevMenuEnabled};
@@ -898,6 +898,8 @@ namespace facebook {
- (void)setProfilingEnabled:(BOOL)isProfilingEnabled;
- (void)toggleElementInspector;
- (void)addMenuItem:(NSString *)title;
- (void)addListener:(NSString *)eventName;
- (void)removeListeners:(double)count;
- (void)setIsShakeToShowDevMenuEnabled:(BOOL)enabled;
@end
@@ -23,6 +23,10 @@ export interface Spec extends TurboModule {
+toggleElementInspector: () => void;
+addMenuItem: (title: string) => void;
// Events
+addListener: (eventName: string) => void;
+removeListeners: (count: number) => void;
// iOS only.
+setIsShakeToShowDevMenuEnabled: (enabled: boolean) => void;
}
@@ -30,6 +30,9 @@ public abstract class NativeDevSettingsSpec extends ReactContextBaseJavaModule i
public void onFastRefresh() {
}
@ReactMethod
public abstract void removeListeners(double count);
@ReactMethod
public abstract void reload();
@@ -51,4 +54,7 @@ public abstract class NativeDevSettingsSpec extends ReactContextBaseJavaModule i
@ReactMethod
public abstract void setIsShakeToShowDevMenuEnabled(boolean enabled);
@ReactMethod
public abstract void addListener(String eventName);
}
@@ -108,4 +108,14 @@ public class DevSettingsModule extends NativeDevSettingsSpec {
public void setIsShakeToShowDevMenuEnabled(boolean enabled) {
// iOS only
}
@Override
public void addListener(String eventName) {
// iOS only
}
@Override
public void removeListeners(double count) {
// iOS only
}
}