Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
a7344227
D
Docs
项目概览
OpenHarmony
/
Docs
接近 2 年 前同步成功
通知
159
Star
292
Fork
28
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
a7344227
编写于
8月 30, 2023
作者:
O
openharmony_ci
提交者:
Gitee
8月 30, 2023
浏览文件
操作
浏览文件
下载
差异文件
!22949 接口一致性修改
Merge pull request !22949 from zhuhan/0824
上级
a5c7419f
116d2395
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
270 addition
and
0 deletion
+270
-0
zh-cn/application-dev/reference/apis/js-apis-commonEventManager.md
...lication-dev/reference/apis/js-apis-commonEventManager.md
+38
-0
zh-cn/application-dev/reference/apis/js-apis-inner-commonEvent-commonEventSubscriber.md
...e/apis/js-apis-inner-commonEvent-commonEventSubscriber.md
+232
-0
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-commonEventManager.md
浏览文件 @
a7344227
...
@@ -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
...
...
zh-cn/application-dev/reference/apis/js-apis-inner-commonEvent-commonEventSubscriber.md
浏览文件 @
a7344227
...
@@ -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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录