From f2b93f2c2b4a1c60da1aadb20b734996d14aaa67 Mon Sep 17 00:00:00 2001 From: chenyuyan Date: Wed, 26 Jul 2023 11:41:59 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=8D=A1=E7=89=87=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E5=8F=82=E6=95=B0=E8=B0=83=E6=95=B4changelog?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: chenyuyan Change-Id: I5e4e7caef2c3555160a6001597d7da610ff1c420 --- .../OpenHarmony_4.0.9.5/changelogs-formfwk.md | 97 ++++++++++++++++++- 1 file changed, 95 insertions(+), 2 deletions(-) diff --git a/zh-cn/release-notes/changelogs/OpenHarmony_4.0.9.5/changelogs-formfwk.md b/zh-cn/release-notes/changelogs/OpenHarmony_4.0.9.5/changelogs-formfwk.md index da84b7dd06..ae1e218d4c 100644 --- a/zh-cn/release-notes/changelogs/OpenHarmony_4.0.9.5/changelogs-formfwk.md +++ b/zh-cn/release-notes/changelogs/OpenHarmony_4.0.9.5/changelogs-formfwk.md @@ -11,8 +11,6 @@ **关键的接口/组件变更** -涉及接口移动、权限修改前的接口原型: - | 接口 | 修改前所属d.ts | 修改后所属d.ts | 修改前所需权限 | 修改后所需权限 | | -------- | -------- | -------- | -------- | -------- | | on('formAdd') | @ohos.app.form.formHost.d.ts | @ohos.app.form.formObserver.d.ts | ohos.permission.REQUIRE_FORM | ohos.permission.OBSERVE_FORM_RUNNING | @ohos.app.form.formHost.d.ts | @ohos.app.form.formObserver.d.ts | ohos.permission.REQUIRE_FORM|ohos.permission.OBSERVE_FORM_RUNNING| @@ -49,3 +47,98 @@ try { } ``` +## cl.formfwk.2 事件订阅,取消订阅相关接口(on/off)参数顺序调整 + +事件订阅,取消订阅相关接口(on/off)中的callback调整为接口最后一个参数。 + +**变更影响** + +对于已发布的js接口,可能影响三方应用的兼容性。 + +**关键的接口/组件变更** + +修改前的接口原型: + +```js +function on(type: 'formAdd', observerCallback: Callback, bundleName?: string): void; +function off(type: 'formAdd', observerCallback?: Callback, bundleName?: string): void; + +function on(type: 'formRemove', observerCallback: Callback, bundleName?: string): void; +function off(type: 'formRemove', observerCallback?: Callback, bundleName?: string): void; + +function on( + type: 'notifyVisible', + observerCallback: Callback>, + hostBundleName?: string + ): void; +function off( + type: 'notifyVisible', + observerCallback?: Callback>, + hostBundleName?: string + ): void; + +function on( + type: 'notifyInvisible', + observerCallback: Callback>, + hostBundleName?: string + ): void; +function off( + type: 'notifyInvisible', + observerCallback?: Callback>, + hostBundleName?: string + ): void; +``` + +修改后的接口原型: + +```js +function on(type: 'formAdd', observerCallback: Callback): void; +function on(type: 'formAdd', hostBundleName: string, observerCallback: Callback): void; +function off(type: 'formAdd', hostBundleName?: string, observerCallback?: Callback): void; + +function on(type: 'formRemove', observerCallback: Callback): void; +function on(type: 'formRemove', hostBundleName: string, observerCallback: Callback): void; +function off(type: 'formRemove', hostBundleName?: string, observerCallback?: Callback): void; + +function on(type: 'notifyVisible', observerCallback: Callback>): void; +function on( + type: 'notifyVisible', + hostBundleName: string, + observerCallback: Callback> + ): void; +function off( + type: 'notifyVisible', + hostBundleName?: string, + observerCallback?: Callback> + ): void; + +function on(type: 'notifyInvisible', observerCallback: Callback>): void; +function on( + type: 'notifyInvisible', + hostBundleName: string, + observerCallback: Callback>, + ): void; +function off( + type: 'notifyInvisible', + hostBundleName?: string, + observerCallback?: Callback> + ): void; +``` + + +**适配指导** + +已使用相关接口开发的应用工程,需要对接口进行适配。从OpenHarmony 4.0.9.5版本起,相关接口使用应注意入参顺序的调整,将callback作为最后一个参数进行接口调用。 + +**示例:** +```js +import formObserver from @ohos.app.form.formObserver.d.ts; + +let bundleName = 'ohos.samples.FormApplication'; +let callback = function(data) { + console.log('a new form added, data: ${JSON.stringify(data)'); +} + +formHost.on('formAdd', callback); +formHost.on('formAdd', bundleName, callback); +``` \ No newline at end of file -- GitLab