From f57fb0117e006d486020564ec9fbed47c37cff73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=95=99=E7=BA=A2=E5=B0=98?= Date: Tue, 1 Jul 2025 09:06:47 +0000 Subject: [PATCH] update zh-cn/application-dev/reference/apis-arkts/js-apis-arkts-utils.md. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 留红尘 --- .../apis-arkts/js-apis-arkts-utils.md | 80 +++++++++---------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/zh-cn/application-dev/reference/apis-arkts/js-apis-arkts-utils.md b/zh-cn/application-dev/reference/apis-arkts/js-apis-arkts-utils.md index 1fded52dc18..d96200a98ba 100644 --- a/zh-cn/application-dev/reference/apis-arkts/js-apis-arkts-utils.md +++ b/zh-cn/application-dev/reference/apis-arkts/js-apis-arkts-utils.md @@ -14,6 +14,46 @@ import { ArkTSUtils } from '@kit.ArkTS' ``` +## isSendable + +isSendable(value: Object | null | undefined): boolean + +该方法用于判断value是否为Sendable数据类型。 + +**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。 + +**系统能力:** SystemCapability.Utils.Lang + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| value | Object \| null \| undefined | 是 | 待校验的对象。| + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| boolean | value是否为Sendable数据类型,true表示value是Sendable数据类型,否则为false。| + +**示例:** + +```ts +import { ArkTSUtils } from '@kit.ArkTS'; + +@Sendable +function sendableFunc() { + console.info("sendableFunc"); +} + +if (ArkTSUtils.isSendable(sendableFunc)) { + console.info("sendableFunc is Sendable"); +} else { + console.info("sendableFunc is not Sendable"); +} +// 期望输出: 'SendableFunc is Sendable' +``` + ## ArkTSUtils.locks 为了解决多并发实例间的数据竞争问题,ArkTS语言基础库引入了异步锁能力。为了开发者的开发效率,AsyncLock对象支持跨并发实例引用传递。 @@ -855,46 +895,6 @@ console.info(str6); //期望输出:'["send","able","set"]' ``` -### isSendable - -isSendable(value: Object | null | undefined): boolean - -该方法用于判断value是否为Sendable数据类型。 - -**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。 - -**系统能力:** SystemCapability.Utils.Lang - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| value | Object \| null \| undefined | 是 | 待校验的对象。| - -**返回值:** - -| 类型 | 说明 | -| -------- | -------- | -| boolean | value是否为Sendable数据类型,true表示value是Sendable数据类型,否则为false。| - -**示例:** - -```ts -import { ArkTSUtils } from '@kit.ArkTS'; - -@Sendable -function sendableFunc() { - console.info("sendableFunc"); -} - -if (ArkTSUtils.isSendable(sendableFunc)) { - console.info("sendableFunc is Sendable"); -} else { - console.info("sendableFunc is not Sendable"); -} -// 期望输出: 'SendableFunc is Sendable' -``` - ## SendableLruCache18+ SendableLruCache在缓存空间不足时,会用新数据替换近期最少使用的数据。此设计基于资源访问的考虑:近期访问的数据可能在不久的将来再次访问,因此最少访问的数据价值最小,应优先移出缓存。SendableLruCache支持Sendable特性,可保存Sendable对象,确保跨线程安全访问。 -- Gitee