From 1256a2b8583028bd6e9faa11b6e42d273f74662a Mon Sep 17 00:00:00 2001 From: XHY Date: Thu, 16 Mar 2023 15:36:06 +0800 Subject: [PATCH] =?UTF-8?q?=E5=86=85=E5=AD=98=E8=AD=A6=E5=91=8A=E6=8F=92?= =?UTF-8?q?=E4=BB=B6=20=E6=96=B9=E6=B3=95=E5=8F=82=E6=95=B0=E6=94=B9?= =?UTF-8?q?=E5=9B=9E=20UTSCallback=20=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../uni-memorywarning/utssdk/app-ios/index.uts | 15 ++++++--------- .../uni-memorywarning/utssdk/interface.uts | 6 ------ 2 files changed, 6 insertions(+), 15 deletions(-) delete mode 100644 uni_modules/uni-memorywarning/utssdk/interface.uts diff --git a/uni_modules/uni-memorywarning/utssdk/app-ios/index.uts b/uni_modules/uni-memorywarning/utssdk/app-ios/index.uts index 97ef23d..e4dc943 100644 --- a/uni_modules/uni-memorywarning/utssdk/app-ios/index.uts +++ b/uni_modules/uni-memorywarning/utssdk/app-ios/index.uts @@ -2,13 +2,11 @@ import { NotificationCenter } from 'Foundation'; import { UIApplication } from "UIKit" import { Selector } from "ObjectiveC" -import { OffMemoryWarning, OnMemoryWarning, OnMemoryWarningCallback, OnMemoryWarningCallbackResult } from "../interface.uts" - class MemoryWarningTool { - static listeners: OnMemoryWarningCallback[] = [] + static listeners: UTSCallback[] = [] // 监听内存警告 - static listenMemoryWarning(callback: OnMemoryWarningCallback) { + static listenMemoryWarning(callback: UTSCallback) { // 只有首次才需要注册监听事件 if (this.listeners.length == 0) { @@ -25,13 +23,12 @@ class MemoryWarningTool { @objc static receiveMemoryWarning() { // 触发回调 this.listeners.forEach(listener => { - const ret: OnMemoryWarningCallbackResult = {} - listener(ret) + listener({}) }) } // 移除监听事件 - static removeListen(callback: OnMemoryWarningCallback | null) { + static removeListen(callback: UTSCallback | null) { // 移除所有监听 if (callback == null) { this.listeners = [] @@ -49,11 +46,11 @@ class MemoryWarningTool { } // 开启监听内存警告 -export const onMemoryWarning : OnMemoryWarning = function (callback: OnMemoryWarningCallback) { +export function onMemoryWarning(callback: UTSCallback) { MemoryWarningTool.listenMemoryWarning(callback) } // 关闭监听内存警告 -export const offMemoryWarning : OffMemoryWarning = function (callback: OnMemoryWarningCallback | null) { +export function offMemoryWarning(callback: UTSCallback | null) { MemoryWarningTool.removeListen(callback) } \ No newline at end of file diff --git a/uni_modules/uni-memorywarning/utssdk/interface.uts b/uni_modules/uni-memorywarning/utssdk/interface.uts deleted file mode 100644 index b3a8615..0000000 --- a/uni_modules/uni-memorywarning/utssdk/interface.uts +++ /dev/null @@ -1,6 +0,0 @@ -export type OnMemoryWarningCallbackResult = { - level : number | null -} -export type OnMemoryWarningCallback = (res : OnMemoryWarningCallbackResult) => void -export type OnMemoryWarning = (callback : OnMemoryWarningCallback) => void -export type OffMemoryWarning = (callback : OnMemoryWarningCallback | null) => void \ No newline at end of file -- GitLab