Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
826a9132
D
Docs
项目概览
OpenHarmony
/
Docs
1 年多 前同步成功
通知
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看板
未验证
提交
826a9132
编写于
4月 02, 2022
作者:
O
openharmony_ci
提交者:
Gitee
4月 02, 2022
浏览文件
操作
浏览文件
下载
差异文件
!2966 2824 处理完成:修改注释和标记api9接口
Merge pull request !2966 from ester.zhou/TR-2824
上级
a2e98362
1310d877
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
37 addition
and
32 deletion
+37
-32
en/application-dev/reference/apis/js-apis-commonEvent.md
en/application-dev/reference/apis/js-apis-commonEvent.md
+37
-32
未找到文件。
en/application-dev/reference/apis/js-apis-commonEvent.md
浏览文件 @
826a9132
...
...
@@ -341,12 +341,12 @@ Creates a subscriber. This API uses a callback to return the result.
```
js
var
subscriber
;
// Used to save the created subscriber object for subsequent subscription and unsubscription.
// Subscriber information
// Subscriber information
.
var
subscribeInfo
=
{
events
:
[
"
event
"
]
};
// Callback for subscriber creation
// Callback for subscriber creation
.
function
CreateSubscriberCallBack
(
err
,
commonEventSubscriber
)
{
if
(
err
.
code
)
{
console
.
error
(
"
createSubscriber failed
"
+
JSON
.
stringify
(
err
));
...
...
@@ -386,7 +386,7 @@ Creates a subscriber. This API uses a promise to return the result.
```
js
var
subscriber
;
// Used to save the created subscriber object for subsequent subscription and unsubscription.
// Subscriber information
// Subscriber information
.
var
subscribeInfo
=
{
events
:
[
"
event
"
]
};
...
...
@@ -422,12 +422,12 @@ Subscribes to common events. This API uses a callback to return the result.
```
js
var
subscriber
;
// Used to save the created subscriber object for subsequent subscription and unsubscription.
// Subscriber information
// Subscriber information
.
var
subscribeInfo
=
{
events
:
[
"
event
"
]
};
// Callback for common event subscription
// Callback for common event subscription
.
function
SubscribeCallBack
(
err
,
data
)
{
if
(
err
.
code
)
{
console
.
error
(
"
subscribe failed
"
+
JSON
.
stringify
(
err
));
...
...
@@ -436,7 +436,7 @@ function SubscribeCallBack(err, data) {
}
}
// Callback for subscriber creation
// Callback for subscriber creation
.
function
CreateSubscriberCallBack
(
err
,
commonEventSubscriber
)
{
if
(
err
.
code
)
{
console
.
error
(
"
createSubscriber failed
"
+
JSON
.
stringify
(
err
));
...
...
@@ -474,12 +474,12 @@ Unsubscribes from common events. This API uses a callback to return the result.
```
js
var
subscriber
;
// Used to save the created subscriber object for subsequent subscription and unsubscription.
// Subscriber information
// Subscriber information
.
var
subscribeInfo
=
{
events
:
[
"
event
"
]
};
// Callback for common event subscription
// Callback for common event subscription
.
function
SubscribeCallBack
(
err
,
data
)
{
if
(
err
.
code
)
{
console
.
info
(
"
subscribe failed
"
+
JSON
.
stringify
(
err
));
...
...
@@ -488,7 +488,7 @@ function SubscribeCallBack(err, data) {
}
}
// Callback for subscriber creation
// Callback for subscriber creation
.
function
CreateSubscriberCallBack
(
err
,
commonEventSubscriber
)
{
if
(
err
.
code
)
{
console
.
info
(
"
createSubscriber failed
"
+
JSON
.
stringify
(
err
));
...
...
@@ -500,7 +500,7 @@ function CreateSubscriberCallBack(err, commonEventSubscriber) {
}
}
// Callback for common event unsubscription
// Callback for common event unsubscription
.
function
UnsubscribeCallBack
(
err
)
{
if
(
err
.
code
)
{
console
.
info
(
"
unsubscribe failed
"
+
JSON
.
stringify
(
err
));
...
...
@@ -537,7 +537,7 @@ Obtains the result code of this common event. This API uses a callback to return
```
js
var
subscriber
;
// Subscriber object successfully created.
// Callback for result
data setting of an ordered common event
// Callback for result
code obtaining of an ordered common event.
function
getCodeCallback
(
err
,
Code
)
{
if
(
err
.
code
)
{
console
.
error
(
"
getCode failed
"
+
JSON
.
stringify
(
err
));
...
...
@@ -594,7 +594,7 @@ Sets the result code for this common event. This API uses a callback to return t
```
js
var
subscriber
;
// Subscriber object successfully created.
// Callback for result
data setting of an ordered common event
// Callback for result
code setting of an ordered common event.
function
setCodeCallback
(
err
)
{
if
(
err
.
code
)
{
console
.
error
(
"
setCode failed
"
+
JSON
.
stringify
(
err
));
...
...
@@ -656,7 +656,7 @@ Obtains the result data of this common event. This API uses a callback to return
```
js
var
subscriber
;
// Subscriber object successfully created.
// Callback for result data
setting of an ordered common event
// Callback for result data
obtaining of an ordered common event.
function
getDataCallback
(
err
,
Data
)
{
if
(
err
.
code
)
{
console
.
error
(
"
getData failed
"
+
JSON
.
stringify
(
err
));
...
...
@@ -742,7 +742,7 @@ Sets the result data for this common event. This API uses a promise to return th
| Type | Description |
| ---------------- | -------------------- |
| Promise
\<
void> | Promise used to return the result.|
| Promise
\<
void> | Promise used to return the result
data
.|
**Example**
...
...
@@ -777,7 +777,7 @@ Sets the result code and result data for this common event. This API uses a call
```
js
var
subscriber
;
// Subscriber object successfully created.
// Callback for result
data setting of an ordered common event
// Callback for result
code and result data setting of an ordered common event.
function
setCodeDataCallback
(
err
)
{
if
(
err
.
code
)
{
console
.
error
(
"
setCodeAndData failed
"
+
JSON
.
stringify
(
err
));
...
...
@@ -840,7 +840,7 @@ Checks whether this common event is an ordered one. This API uses a callback to
```
js
var
subscriber
;
// Subscriber object successfully created.
// Callback for
result data setting of an ordered common event
// Callback for
checking whether the current common event is an ordered one.
function
isOrderedCallback
(
err
,
isOrdered
)
{
if
(
err
.
code
)
{
console
.
error
(
"
isOrderedCommonEvent failed
"
+
JSON
.
stringify
(
err
));
...
...
@@ -896,7 +896,7 @@ Checks whether this common event is a sticky one. This API uses a callback to re
```
js
var
subscriber
;
// Subscriber object successfully created.
// Callback for
result data setting of an ordered common event
// Callback for
checking whether the current common event is a sticky one.
function
isStickyCallback
(
err
,
isSticky
)
{
if
(
err
.
code
)
{
console
.
error
(
"
isStickyCommonEvent failed
"
+
JSON
.
stringify
(
err
));
...
...
@@ -952,7 +952,7 @@ Aborts this common event. After the abort, the common event is not sent to the n
```
js
var
subscriber
;
// Subscriber object successfully created.
// Callback for
result data setting of an ordered common event
// Callback for
common event aborting.
function
abortCallback
(
err
)
{
if
(
err
.
code
)
{
console
.
error
(
"
abortCommonEvent failed
"
+
JSON
.
stringify
(
err
));
...
...
@@ -1008,7 +1008,7 @@ Clears the aborted state of this common event. This API takes effect only for or
```
js
var
subscriber
;
// Subscriber object successfully created.
// Callback for
result data setting of an ordered common event
// Callback for
clearing the aborted state of the current common event.
function
clearAbortCallback
(
err
)
{
if
(
err
.
code
)
{
console
.
error
(
"
clearAbortCommonEvent failed
"
+
JSON
.
stringify
(
err
));
...
...
@@ -1064,7 +1064,7 @@ Checks whether this common event is in the aborted state. This API takes effect
```
js
var
subscriber
;
// Subscriber object successfully created.
// Callback for
result data setting of an ordered common event
// Callback for
checking whether the current common event is in the aborted state.
function
getAbortCallback
(
err
,
AbortCommonEvent
)
{
if
(
err
.
code
)
{
console
.
error
(
"
getAbortCommonEvent failed
"
+
JSON
.
stringify
(
err
));
...
...
@@ -1120,7 +1120,7 @@ Obtains the subscriber information. This API uses a callback to return the resul
```
js
var
subscriber
;
// Subscriber object successfully created.
// Callback for
result data setting of an ordered common event
// Callback for
subscriber information obtaining.
function
getSubscribeInfoCallback
(
err
,
SubscribeInfo
)
{
if
(
err
.
code
)
{
console
.
error
(
"
getSubscribeInfo failed
"
+
JSON
.
stringify
(
err
));
...
...
@@ -1157,11 +1157,11 @@ subscriber.getSubscribeInfo().then((SubscribeInfo) => {
});
```
### finishCommonEvent
### finishCommonEvent
<sup>9+</sup>
finishCommonEvent(callback: AsyncCallback
\<
void
\>
): void
Ends the sorted common events
. This API uses a callback to return the result.
Finishes this ordered common event
. This API uses a callback to return the result.
**System capability**
: SystemCapability.Notification.CommonEvent
...
...
@@ -1169,25 +1169,29 @@ Ends the sorted common events. This API uses a callback to return the result.
| Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | -------------------------------- |
| callback | AsyncCallback
\<
void> | Yes | Callback
used to return the result
.|
| callback | AsyncCallback
\<
void> | Yes | Callback
returned after the ordered common event is finished
.|
**Example**
```
js
var
subscriber
;
// Subscriber object successfully created.
// Callback for ordered common event finishing.
function
finishCommonEventCallback
()
{
console
.
log
(
"
--------- finishCommonEventCallback ----------
"
);
if
(
err
.
code
)
{
console
.
error
(
"
finishCommonEvent failed
"
+
JSON
.
stringify
(
err
));
}
else
{
console
.
info
(
"
FinishCommonEvent
"
);
}
}
subscriber
.
finishCommonEvent
(
finishCommonEventCallback
);
```
### finishCommonEvent
### finishCommonEvent
<sup>9+</sup>
finishCommonEvent(): Promise
\<
void
\>
Ends the sorted common events
. This API uses a promise to return the result.
Finishes this ordered common event
. This API uses a promise to return the result.
**System capability**
: SystemCapability.Notification.CommonEvent
...
...
@@ -1202,10 +1206,11 @@ Ends the sorted common events. This API uses a promise to return the result.
```
js
var
subscriber
;
// Subscriber object successfully created.
subscriber
.
finishCommonEvent
()
.
then
(()
=>
{
console
.
info
(
"
--------- finishCommonEventCallback ----------
"
);
})
subscriber
.
finishCommonEvent
().
then
(()
=>
{
console
.
info
(
"
FinishCommonEvent
"
);
}).
catch
((
err
)
=>
{
console
.
error
(
"
finishCommonEvent failed
"
+
JSON
.
stringify
(
err
));
});
```
## CommonEventData
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录