From d538782b019b18f6de2bbc7498d83f57e2979176 Mon Sep 17 00:00:00 2001 From: steven Date: Mon, 20 Feb 2023 14:36:08 +0800 Subject: [PATCH] fix: fix NativeEventEmitter warning --- Example/testHotUpdate/android/gradle.properties | 2 +- .../cn/reactnative/modules/update/UpdateModule.java | 13 ++++++++++++- lib/NativeUpdate.js | 2 ++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Example/testHotUpdate/android/gradle.properties b/Example/testHotUpdate/android/gradle.properties index e4af465..e1ddc51 100644 --- a/Example/testHotUpdate/android/gradle.properties +++ b/Example/testHotUpdate/android/gradle.properties @@ -37,7 +37,7 @@ reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64 # your application. You should enable this flag either if you want # to write custom TurboModules/Fabric components OR use libraries that # are providing them. -newArchEnabled=false +newArchEnabled=true # Use this property to enable or disable the Hermes JS engine. # If set to false, you will be using JSC instead. diff --git a/android/src/newarch/cn/reactnative/modules/update/UpdateModule.java b/android/src/newarch/cn/reactnative/modules/update/UpdateModule.java index 05a57f4..0a6dd1d 100644 --- a/android/src/newarch/cn/reactnative/modules/update/UpdateModule.java +++ b/android/src/newarch/cn/reactnative/modules/update/UpdateModule.java @@ -127,7 +127,18 @@ public class UpdateModule extends NativeUpdateSpec { public void getLocalHashInfo(final String hash, final Promise promise) { UpdateModuleImpl.getLocalHashInfo(updateContext,hash,promise); } - + + @Override + public void addListener(String eventName) { + // Set up any upstream listeners or background tasks as necessary + } + + @Override + public void removeListeners(double count) { + // Remove upstream listeners, stop unnecessary background tasks + } + + /* 发送事件*/ public static void sendEvent(String eventName, WritableMap params) { ((ReactContext) mContext).getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit(eventName, diff --git a/lib/NativeUpdate.js b/lib/NativeUpdate.js index 4706eac..e4668d0 100644 --- a/lib/NativeUpdate.js +++ b/lib/NativeUpdate.js @@ -44,6 +44,8 @@ export interface Spec extends TurboModule { target: string, hash: string, }): Promise; + addListener(eventName: string): void; + removeListeners(count: number): void; } export default (TurboModuleRegistry.get('Pushy'): ?Spec);