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

!5676 翻译完成 4442:Fix wrong example code of Notification docs

Merge pull request !5676 from ester.zhou/TR-4442
# CommonEvent # CommonEvent
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > **NOTE**
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Required Permissions ## Required Permissions
...@@ -181,7 +181,7 @@ Publishes a common event. This API uses a callback to return the result. ...@@ -181,7 +181,7 @@ Publishes a common event. This API uses a callback to return the result.
**Example** **Example**
```js ```js
// Callback for common event publication // Callback for common event publication.
function PublishCallBack(err) { function PublishCallBack(err) {
if (err.code) { if (err.code) {
console.error("publish failed " + JSON.stringify(err)); console.error("publish failed " + JSON.stringify(err));
...@@ -219,7 +219,7 @@ Publishes a common event with given attributes. This API uses a callback to retu ...@@ -219,7 +219,7 @@ Publishes a common event with given attributes. This API uses a callback to retu
// Attributes of a common event. // Attributes of a common event.
var options = { var options = {
code: 0, // Result code of the common event code: 0, // Result code of the common event
data: "initial data";// Result data of the common event data: "initial data",// Result data of the common event
isOrdered: true // The common event is an ordered one. isOrdered: true // The common event is an ordered one.
} }
...@@ -257,7 +257,7 @@ Publishes a common event to a specific user. This API uses a callback to return ...@@ -257,7 +257,7 @@ Publishes a common event to a specific user. This API uses a callback to return
**Example** **Example**
```js ```js
// Callback for common event publication // Callback for common event publication.
function PublishAsUserCallBack(err) { function PublishAsUserCallBack(err) {
if (err.code) { if (err.code) {
console.error("publishAsUser failed " + JSON.stringify(err)); console.error("publishAsUser failed " + JSON.stringify(err));
...@@ -299,7 +299,7 @@ Publishes a common event with given attributes to a specific user. This API uses ...@@ -299,7 +299,7 @@ Publishes a common event with given attributes to a specific user. This API uses
// Attributes of a common event. // Attributes of a common event.
var options = { var options = {
code: 0, // Result code of the common event code: 0, // Result code of the common event
data: "initial data";// Result data of the common event data: "initial data",// Result data of the common event
} }
// Callback for common event publication // Callback for common event publication
...@@ -1177,12 +1177,12 @@ Finishes this ordered common event. This API uses a callback to return the resul ...@@ -1177,12 +1177,12 @@ Finishes this ordered common event. This API uses a callback to return the resul
var subscriber; // Subscriber object successfully created. var subscriber; // Subscriber object successfully created.
// Callback for ordered common event finishing. // Callback for ordered common event finishing.
function finishCommonEventCallback() { function finishCommonEventCallback(err) {
if (err.code) { if (err.code) {
console.error("finishCommonEvent failed " + JSON.stringify(err)); console.error("finishCommonEvent failed " + JSON.stringify(err));
} else { } else {
console.info("FinishCommonEvent"); console.info("FinishCommonEvent");
} }
} }
subscriber.finishCommonEvent(finishCommonEventCallback); subscriber.finishCommonEvent(finishCommonEventCallback);
``` ```
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册