未验证 提交 833a823b 编写于 作者: O openharmony_ci 提交者: Gitee

!22950 接口一致性修改monthly

Merge pull request !22950 from zhuhan/cherry-pick-1692879942
......@@ -312,6 +312,44 @@ CommonEventManager.createSubscriber(subscribeInfo).then((commonEventSubscriber)
```
## CommonEventManager.createSubscriberSync
createSubscriberSync(subscribeInfo: CommonEventSubscribeInfo): CommonEventSubscriber
createSubscriber的同步接口。
**系统能力:** SystemCapability.Notification.CommonEvent
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------------- | ----------------------------------------------------- | ---- | -------------- |
| subscribeInfo | [CommonEventSubscribeInfo](./js-apis-inner-commonEvent-commonEventSubscribeInfo.md) | 是 | 表示订阅信息。 |
**返回值:**
| 类型 | 说明 |
| --------------------------------------------------------- | ---------------- |
| [CommonEventSubscriber](./js-apis-inner-commonEvent-commonEventSubscriber.md) | 返回订阅者对象。 |
**示例:**
```ts
let subscriber; //用于保存创建成功的订阅者对象,后续使用其完成订阅及退订的动作
//订阅者信息
let subscribeInfo = {
events: ["event"]
};
//创建订阅者
try {
subscriber = CommonEventManager.createSubscriberSync(subscribeInfo);
} catch (err) {
console.error(`createSubscriberSync failed, code is ${err.code}, message is ${err.message}`);
}
```
## CommonEventManager.subscribe
subscribe(subscriber: CommonEventSubscriber, callback: AsyncCallback\<CommonEventData>): void
......
......@@ -83,6 +83,27 @@ subscriber.getCode().then((code) => {
});
```
## getCodeSync
getCodeSync(): number
getCode的同步接口
**系统能力**`SystemCapability.Notification.CommonEvent`
**返回值:**
| 类型 | 说明 |
| ---------------- | -------------------- |
| number | 公共事件代码。 |
**示例:**
```ts
let code = subscriber.getCodeSync();
console.info("getCodeSync " + JSON.stringify(code));
```
## setCode
setCode(code: number, callback: AsyncCallback\<void>): void
......@@ -142,6 +163,32 @@ subscriber.setCode(1).then(() => {
});
```
## setCodeSync
setCodeSync(code: number): void
setCode的同步接口
**系统能力**`SystemCapability.Notification.CommonEvent`
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ------------------ |
| code | number | 是 | 公共事件的代码。 |
**示例:**
```ts
try {
subscriber.setCodeSync(1);
} catch (err) {
console.error(`setCodeSync failed, code is ${err.code}, message is ${err.message}`);
}
```
## getData
getData(callback: AsyncCallback\<string>): void
......@@ -194,6 +241,27 @@ subscriber.getData().then((data) => {
});
```
## getDataSync
getDataSync(): string
getData的同步接口
**系统能力**`SystemCapability.Notification.CommonEvent`
**返回值:**
| 类型 | 说明 |
| ---------------- | ------------------ |
| string | 公共事件的数据。 |
**示例:**
```ts
let data = subscriber.getDataSync();
console.info("getDataSync " + JSON.stringify(data));
```
## setData
setData(data: string, callback: AsyncCallback\<void>): void
......@@ -253,6 +321,29 @@ subscriber.setData("publish_data_changed").then(() => {
});
```
## setDataSync
setDataSync(data: string): void
setData的同步接口。
**系统能力**`SystemCapability.Notification.CommonEvent`
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | -------------------- |
| data | string | 是 | 公共事件的数据。 |
**示例:**
```ts
try {
subscriber.setDataSync("publish_data_changed");
} catch (err) {
console.error(`setDataSync failed, code is ${err.code}, message is ${err.message}`);
}
```
## setCodeAndData
setCodeAndData(code: number, data: string, callback:AsyncCallback\<void>): void
......@@ -314,6 +405,31 @@ subscriber.setCodeAndData(1, "publish_data_changed").then(() => {
});
```
## setCodeAndDataSync
setCodeAndData的同步接口。
setCodeAndDataSync(code: number, data: string): void
**系统能力**`SystemCapability.Notification.CommonEvent`
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | -------------------- |
| code | number | 是 | 公共事件的代码。 |
| data | string | 是 | 公共事件的数据。 |
**示例:**
```ts
try {
subscriber.setCodeAndDataSync(1, "publish_data_changed");
} catch (err) {
console.error(`setCodeAndData failed, code is ${err.code}, message is ${err.message}`);
}
```
## isOrderedCommonEvent
isOrderedCommonEvent(callback: AsyncCallback\<boolean>): void
......@@ -370,6 +486,29 @@ subscriber.isOrderedCommonEvent().then((isOrdered) => {
});
```
## isOrderedCommonEventSync
isOrderedCommonEventSync(): boolean
isOrderedCommonEvent的同步接口
返回true代表是有序公共事件,false代表不是有序公共事件。
**系统能力**`SystemCapability.Notification.CommonEvent`
**返回值:**
| 类型 | 说明 |
| ----------------- | -------------------------------- |
| boolean | 当前公共事件的是否为有序公共事件。 |
**示例:**
```ts
let isOrdered = subscriber.isOrderedCommonEventSync();
console.info("isOrdered " + JSON.stringify(isOrdered));
```
## isStickyCommonEvent
isStickyCommonEvent(callback: AsyncCallback\<boolean>): void
......@@ -426,6 +565,29 @@ subscriber.isStickyCommonEvent().then((isSticky) => {
});
```
## isStickyCommonEventSync
isStickyCommonEventSync(): boolean
isStickyCommonEvent的同步接口。
返回true代表是粘性公共事件,false代表不是粘性公共事件。
**系统能力**`SystemCapability.Notification.CommonEvent`
**返回值:**
| 类型 | 说明 |
| ----------------- | -------------------------------- |
| boolean | 当前公共事件的是否为粘性公共事件。 |
**示例:**
```ts
let isSticky = subscriber.isStickyCommonEventSync();
console.info("isSticky " + JSON.stringify(isSticky));
```
## abortCommonEvent
abortCommonEvent(callback: AsyncCallback\<void>): void
......@@ -478,6 +640,20 @@ subscriber.abortCommonEvent().then(() => {
});
```
## abortCommonEventSync
abortCommonEventSync(): void
abortCommonEvent的同步接口
**系统能力**`SystemCapability.Notification.CommonEvent`
**示例:**
```ts
subscriber.abortCommonEventSync();
```
## clearAbortCommonEvent
clearAbortCommonEvent(callback: AsyncCallback\<void>): void
......@@ -530,6 +706,20 @@ subscriber.clearAbortCommonEvent().then(() => {
});
```
## clearAbortCommonEventSync
clearAbortCommonEventSync(): void
clearAbortCommonEvent的同步接口
**系统能力**`SystemCapability.Notification.CommonEvent`
**示例:**
```ts
subscriber.clearAbortCommonEventSync()
```
## getAbortCommonEvent
getAbortCommonEvent(callback: AsyncCallback\<boolean>): void
......@@ -582,6 +772,27 @@ subscriber.getAbortCommonEvent().then((abortEvent) => {
});
```
## getAbortCommonEventSync
getAbortCommonEventSync(): boolean
getAbortCommonEvent的同步接口。
**系统能力**`SystemCapability.Notification.CommonEvent`
**返回值:**
| 类型 | 说明 |
| ----------------- | ---------------------------------- |
| boolean | 表示当前有序公共事件是否取消的状态。 |
**示例:**
```ts
let abortEvent = subscriber.getAbortCommonEventSync();
console.info("getAbortCommonEventSync " + JSON.stringify(abortEvent));
```
## getSubscribeInfo
getSubscribeInfo(callback: AsyncCallback\<CommonEventSubscribeInfo>): void
......@@ -634,6 +845,27 @@ subscriber.getSubscribeInfo().then((subscribeInfo) => {
});
```
## getSubscribeInfoSync
getSubscribeInfoSync(): CommonEventSubscribeInfo
getSubscribeInfo的同步接口。
**系统能力**`SystemCapability.Notification.CommonEvent`
**返回值:**
| 类型 | 说明 |
| ------------------------------------------------------------ | ---------------------- |
| [CommonEventSubscribeInfo](./js-apis-inner-commonEvent-commonEventSubscribeInfo.md) | 表示订阅者的订阅信息。 |
**示例:**
```ts
let subscribeInfo = subscriber.getSubscribeInfoSync();
console.info("subscribeInfo " + JSON.stringify(subscribeInfo));
```
## finishCommonEvent<sup>9+</sup>
finishCommonEvent(callback: AsyncCallback\<void>): void
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册