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

!22949 接口一致性修改

Merge pull request !22949 from zhuhan/0824
...@@ -313,6 +313,44 @@ CommonEventManager.createSubscriber(subscribeInfo).then((commonEventSubscriber:C ...@@ -313,6 +313,44 @@ CommonEventManager.createSubscriber(subscribeInfo).then((commonEventSubscriber:C
``` ```
## 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 ## CommonEventManager.subscribe
subscribe(subscriber: CommonEventSubscriber, callback: AsyncCallback\<CommonEventData>): void subscribe(subscriber: CommonEventSubscriber, callback: AsyncCallback\<CommonEventData>): void
......
...@@ -85,6 +85,27 @@ subscriber.getCode().then((code:number) => { ...@@ -85,6 +85,27 @@ subscriber.getCode().then((code:number) => {
}); });
``` ```
## getCodeSync
getCodeSync(): number
getCode的同步接口
**系统能力**`SystemCapability.Notification.CommonEvent`
**返回值:**
| 类型 | 说明 |
| ---------------- | -------------------- |
| number | 公共事件代码。 |
**示例:**
```ts
let code = subscriber.getCodeSync();
console.info("getCodeSync " + JSON.stringify(code));
```
## setCode ## setCode
setCode(code: number, callback: AsyncCallback\<void>): void setCode(code: number, callback: AsyncCallback\<void>): void
...@@ -144,6 +165,32 @@ subscriber.setCode(1).then(() => { ...@@ -144,6 +165,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
getData(callback: AsyncCallback\<string>): void getData(callback: AsyncCallback\<string>): void
...@@ -196,6 +243,27 @@ subscriber.getData().then((data:string) => { ...@@ -196,6 +243,27 @@ subscriber.getData().then((data:string) => {
}); });
``` ```
## getDataSync
getDataSync(): string
getData的同步接口
**系统能力**`SystemCapability.Notification.CommonEvent`
**返回值:**
| 类型 | 说明 |
| ---------------- | ------------------ |
| string | 公共事件的数据。 |
**示例:**
```ts
let data = subscriber.getDataSync();
console.info("getDataSync " + JSON.stringify(data));
```
## setData ## setData
setData(data: string, callback: AsyncCallback\<void>): void setData(data: string, callback: AsyncCallback\<void>): void
...@@ -255,6 +323,29 @@ subscriber.setData("publish_data_changed").then(() => { ...@@ -255,6 +323,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
setCodeAndData(code: number, data: string, callback:AsyncCallback\<void>): void setCodeAndData(code: number, data: string, callback:AsyncCallback\<void>): void
...@@ -316,6 +407,31 @@ subscriber.setCodeAndData(1, "publish_data_changed").then(() => { ...@@ -316,6 +407,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
isOrderedCommonEvent(callback: AsyncCallback\<boolean>): void isOrderedCommonEvent(callback: AsyncCallback\<boolean>): void
...@@ -372,6 +488,29 @@ subscriber.isOrderedCommonEvent().then((isOrdered:boolean) => { ...@@ -372,6 +488,29 @@ subscriber.isOrderedCommonEvent().then((isOrdered:boolean) => {
}); });
``` ```
## isOrderedCommonEventSync
isOrderedCommonEventSync(): boolean
isOrderedCommonEvent的同步接口
返回true代表是有序公共事件,false代表不是有序公共事件。
**系统能力**`SystemCapability.Notification.CommonEvent`
**返回值:**
| 类型 | 说明 |
| ----------------- | -------------------------------- |
| boolean | 当前公共事件的是否为有序公共事件。 |
**示例:**
```ts
let isOrdered = subscriber.isOrderedCommonEventSync();
console.info("isOrdered " + JSON.stringify(isOrdered));
```
## isStickyCommonEvent ## isStickyCommonEvent
isStickyCommonEvent(callback: AsyncCallback\<boolean>): void isStickyCommonEvent(callback: AsyncCallback\<boolean>): void
...@@ -428,6 +567,29 @@ subscriber.isStickyCommonEvent().then((isSticky:boolean) => { ...@@ -428,6 +567,29 @@ subscriber.isStickyCommonEvent().then((isSticky:boolean) => {
}); });
``` ```
## isStickyCommonEventSync
isStickyCommonEventSync(): boolean
isStickyCommonEvent的同步接口。
返回true代表是粘性公共事件,false代表不是粘性公共事件。
**系统能力**`SystemCapability.Notification.CommonEvent`
**返回值:**
| 类型 | 说明 |
| ----------------- | -------------------------------- |
| boolean | 当前公共事件的是否为粘性公共事件。 |
**示例:**
```ts
let isSticky = subscriber.isStickyCommonEventSync();
console.info("isSticky " + JSON.stringify(isSticky));
```
## abortCommonEvent ## abortCommonEvent
abortCommonEvent(callback: AsyncCallback\<void>): void abortCommonEvent(callback: AsyncCallback\<void>): void
...@@ -480,6 +642,20 @@ subscriber.abortCommonEvent().then(() => { ...@@ -480,6 +642,20 @@ subscriber.abortCommonEvent().then(() => {
}); });
``` ```
## abortCommonEventSync
abortCommonEventSync(): void
abortCommonEvent的同步接口
**系统能力**`SystemCapability.Notification.CommonEvent`
**示例:**
```ts
subscriber.abortCommonEventSync();
```
## clearAbortCommonEvent ## clearAbortCommonEvent
clearAbortCommonEvent(callback: AsyncCallback\<void>): void clearAbortCommonEvent(callback: AsyncCallback\<void>): void
...@@ -532,6 +708,20 @@ subscriber.clearAbortCommonEvent().then(() => { ...@@ -532,6 +708,20 @@ subscriber.clearAbortCommonEvent().then(() => {
}); });
``` ```
## clearAbortCommonEventSync
clearAbortCommonEventSync(): void
clearAbortCommonEvent的同步接口
**系统能力**`SystemCapability.Notification.CommonEvent`
**示例:**
```ts
subscriber.clearAbortCommonEventSync()
```
## getAbortCommonEvent ## getAbortCommonEvent
getAbortCommonEvent(callback: AsyncCallback\<boolean>): void getAbortCommonEvent(callback: AsyncCallback\<boolean>): void
...@@ -584,6 +774,27 @@ subscriber.getAbortCommonEvent().then((abortEvent:boolean) => { ...@@ -584,6 +774,27 @@ subscriber.getAbortCommonEvent().then((abortEvent:boolean) => {
}); });
``` ```
## getAbortCommonEventSync
getAbortCommonEventSync(): boolean
getAbortCommonEvent的同步接口。
**系统能力**`SystemCapability.Notification.CommonEvent`
**返回值:**
| 类型 | 说明 |
| ----------------- | ---------------------------------- |
| boolean | 表示当前有序公共事件是否取消的状态。 |
**示例:**
```ts
let abortEvent = subscriber.getAbortCommonEventSync();
console.info("getAbortCommonEventSync " + JSON.stringify(abortEvent));
```
## getSubscribeInfo ## getSubscribeInfo
getSubscribeInfo(callback: AsyncCallback\<CommonEventSubscribeInfo>): void getSubscribeInfo(callback: AsyncCallback\<CommonEventSubscribeInfo>): void
...@@ -636,6 +847,27 @@ subscriber.getSubscribeInfo().then((subscribeInfo:CommonEventManager.CommonEvent ...@@ -636,6 +847,27 @@ subscriber.getSubscribeInfo().then((subscribeInfo:CommonEventManager.CommonEvent
}); });
``` ```
## 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<sup>9+</sup>
finishCommonEvent(callback: AsyncCallback\<void>): void finishCommonEvent(callback: AsyncCallback\<void>): void
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册