diff --git a/uni_modules/uni-memorywarning/utssdk/app-ios/index.uts b/uni_modules/uni-memorywarning/utssdk/app-ios/index.uts index 97ef23d4106e5be1875f8c31d7fbbdf5d1e4e64c..e4dc943ebbcd8df81034a7b0ba4929f2a00b29be 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 b3a8615beaae2c07a251e98b4a95f1db2db31837..0000000000000000000000000000000000000000 --- 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