提交 1310d877 编写于 作者: E ester.zhou

update doc

Signed-off-by: Nester.zhou <ester.zhou@huawei.com>
上级 9507cd00
...@@ -341,12 +341,12 @@ Creates a subscriber. This API uses a callback to return the result. ...@@ -341,12 +341,12 @@ Creates a subscriber. This API uses a callback to return the result.
```js ```js
var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription. var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription.
// Subscriber information // Subscriber information.
var subscribeInfo = { var subscribeInfo = {
events: ["event"] events: ["event"]
}; };
// Callback for subscriber creation // Callback for subscriber creation.
function CreateSubscriberCallBack(err, commonEventSubscriber) { function CreateSubscriberCallBack(err, commonEventSubscriber) {
if (err.code) { if (err.code) {
console.error("createSubscriber failed " + JSON.stringify(err)); console.error("createSubscriber failed " + JSON.stringify(err));
...@@ -386,7 +386,7 @@ Creates a subscriber. This API uses a promise to return the result. ...@@ -386,7 +386,7 @@ Creates a subscriber. This API uses a promise to return the result.
```js ```js
var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription. var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription.
// Subscriber information // Subscriber information.
var subscribeInfo = { var subscribeInfo = {
events: ["event"] events: ["event"]
}; };
...@@ -422,12 +422,12 @@ Subscribes to common events. This API uses a callback to return the result. ...@@ -422,12 +422,12 @@ Subscribes to common events. This API uses a callback to return the result.
```js ```js
var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription. var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription.
// Subscriber information // Subscriber information.
var subscribeInfo = { var subscribeInfo = {
events: ["event"] events: ["event"]
}; };
// Callback for common event subscription // Callback for common event subscription.
function SubscribeCallBack(err, data) { function SubscribeCallBack(err, data) {
if (err.code) { if (err.code) {
console.error("subscribe failed " + JSON.stringify(err)); console.error("subscribe failed " + JSON.stringify(err));
...@@ -436,7 +436,7 @@ function SubscribeCallBack(err, data) { ...@@ -436,7 +436,7 @@ function SubscribeCallBack(err, data) {
} }
} }
// Callback for subscriber creation // Callback for subscriber creation.
function CreateSubscriberCallBack(err, commonEventSubscriber) { function CreateSubscriberCallBack(err, commonEventSubscriber) {
if (err.code) { if (err.code) {
console.error("createSubscriber failed " + JSON.stringify(err)); console.error("createSubscriber failed " + JSON.stringify(err));
...@@ -474,12 +474,12 @@ Unsubscribes from common events. This API uses a callback to return the result. ...@@ -474,12 +474,12 @@ Unsubscribes from common events. This API uses a callback to return the result.
```js ```js
var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription. var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription.
// Subscriber information // Subscriber information.
var subscribeInfo = { var subscribeInfo = {
events: ["event"] events: ["event"]
}; };
// Callback for common event subscription // Callback for common event subscription.
function SubscribeCallBack(err, data) { function SubscribeCallBack(err, data) {
if (err.code) { if (err.code) {
console.info("subscribe failed " + JSON.stringify(err)); console.info("subscribe failed " + JSON.stringify(err));
...@@ -488,7 +488,7 @@ function SubscribeCallBack(err, data) { ...@@ -488,7 +488,7 @@ function SubscribeCallBack(err, data) {
} }
} }
// Callback for subscriber creation // Callback for subscriber creation.
function CreateSubscriberCallBack(err, commonEventSubscriber) { function CreateSubscriberCallBack(err, commonEventSubscriber) {
if (err.code) { if (err.code) {
console.info("createSubscriber failed " + JSON.stringify(err)); console.info("createSubscriber failed " + JSON.stringify(err));
...@@ -500,7 +500,7 @@ function CreateSubscriberCallBack(err, commonEventSubscriber) { ...@@ -500,7 +500,7 @@ function CreateSubscriberCallBack(err, commonEventSubscriber) {
} }
} }
// Callback for common event unsubscription // Callback for common event unsubscription.
function UnsubscribeCallBack(err) { function UnsubscribeCallBack(err) {
if (err.code) { if (err.code) {
console.info("unsubscribe failed " + JSON.stringify(err)); 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 ...@@ -537,7 +537,7 @@ Obtains the result code of this common event. This API uses a callback to return
```js ```js
var subscriber; // Subscriber object successfully created. 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) { function getCodeCallback(err, Code) {
if (err.code) { if (err.code) {
console.error("getCode failed " + JSON.stringify(err)); 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 ...@@ -594,7 +594,7 @@ Sets the result code for this common event. This API uses a callback to return t
```js ```js
var subscriber; // Subscriber object successfully created. 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) { function setCodeCallback(err) {
if (err.code) { if (err.code) {
console.error("setCode failed " + JSON.stringify(err)); 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 ...@@ -656,7 +656,7 @@ Obtains the result data of this common event. This API uses a callback to return
```js ```js
var subscriber; // Subscriber object successfully created. 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) { function getDataCallback(err, Data) {
if (err.code) { if (err.code) {
console.error("getData failed " + JSON.stringify(err)); 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 ...@@ -742,7 +742,7 @@ Sets the result data for this common event. This API uses a promise to return th
| Type | Description | | Type | Description |
| ---------------- | -------------------- | | ---------------- | -------------------- |
| Promise\<void> | Promise used to return the result.| | Promise\<void> | Promise used to return the result data.|
**Example** **Example**
...@@ -777,7 +777,7 @@ Sets the result code and result data for this common event. This API uses a call ...@@ -777,7 +777,7 @@ Sets the result code and result data for this common event. This API uses a call
```js ```js
var subscriber; // Subscriber object successfully created. 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) { function setCodeDataCallback(err) {
if (err.code) { if (err.code) {
console.error("setCodeAndData failed " + JSON.stringify(err)); 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 ...@@ -840,7 +840,7 @@ Checks whether this common event is an ordered one. This API uses a callback to
```js ```js
var subscriber; // Subscriber object successfully created. 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) { function isOrderedCallback(err, isOrdered) {
if (err.code) { if (err.code) {
console.error("isOrderedCommonEvent failed " + JSON.stringify(err)); 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 ...@@ -896,7 +896,7 @@ Checks whether this common event is a sticky one. This API uses a callback to re
```js ```js
var subscriber; // Subscriber object successfully created. 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) { function isStickyCallback(err, isSticky) {
if (err.code) { if (err.code) {
console.error("isStickyCommonEvent failed " + JSON.stringify(err)); 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 ...@@ -952,7 +952,7 @@ Aborts this common event. After the abort, the common event is not sent to the n
```js ```js
var subscriber; // Subscriber object successfully created. var subscriber; // Subscriber object successfully created.
// Callback for result data setting of an ordered common event // Callback for common event aborting.
function abortCallback(err) { function abortCallback(err) {
if (err.code) { if (err.code) {
console.error("abortCommonEvent failed " + JSON.stringify(err)); 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 ...@@ -1008,7 +1008,7 @@ Clears the aborted state of this common event. This API takes effect only for or
```js ```js
var subscriber; // Subscriber object successfully created. 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) { function clearAbortCallback(err) {
if (err.code) { if (err.code) {
console.error("clearAbortCommonEvent failed " + JSON.stringify(err)); 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 ...@@ -1064,7 +1064,7 @@ Checks whether this common event is in the aborted state. This API takes effect
```js ```js
var subscriber; // Subscriber object successfully created. 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) { function getAbortCallback(err, AbortCommonEvent) {
if (err.code) { if (err.code) {
console.error("getAbortCommonEvent failed " + JSON.stringify(err)); console.error("getAbortCommonEvent failed " + JSON.stringify(err));
...@@ -1120,7 +1120,7 @@ Obtains the subscriber information. This API uses a callback to return the resul ...@@ -1120,7 +1120,7 @@ Obtains the subscriber information. This API uses a callback to return the resul
```js ```js
var subscriber; // Subscriber object successfully created. 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) { function getSubscribeInfoCallback(err, SubscribeInfo) {
if (err.code) { if (err.code) {
console.error("getSubscribeInfo failed " + JSON.stringify(err)); console.error("getSubscribeInfo failed " + JSON.stringify(err));
...@@ -1157,11 +1157,11 @@ subscriber.getSubscribeInfo().then((SubscribeInfo) => { ...@@ -1157,11 +1157,11 @@ subscriber.getSubscribeInfo().then((SubscribeInfo) => {
}); });
``` ```
### finishCommonEvent ### finishCommonEvent<sup>9+</sup>
finishCommonEvent(callback: AsyncCallback\<void\>): void 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 **System capability**: SystemCapability.Notification.CommonEvent
...@@ -1169,25 +1169,29 @@ Ends the sorted common events. This API uses a callback to return the result. ...@@ -1169,25 +1169,29 @@ Ends the sorted common events. This API uses a callback to return the result.
| Name | Type | Mandatory| Description | | 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** **Example**
```js ```js
var subscriber; // Subscriber object successfully created. var subscriber; // Subscriber object successfully created.
// Callback for ordered common event finishing.
function finishCommonEventCallback() { function finishCommonEventCallback() {
console.log("--------- finishCommonEventCallback ----------"); if (err.code) {
console.error("finishCommonEvent failed " + JSON.stringify(err));
} else {
console.info("FinishCommonEvent");
}
} }
subscriber.finishCommonEvent(finishCommonEventCallback); subscriber.finishCommonEvent(finishCommonEventCallback);
``` ```
### finishCommonEvent ### finishCommonEvent<sup>9+</sup>
finishCommonEvent(): Promise\<void\> 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 **System capability**: SystemCapability.Notification.CommonEvent
...@@ -1202,10 +1206,11 @@ Ends the sorted common events. This API uses a promise to return the result. ...@@ -1202,10 +1206,11 @@ Ends the sorted common events. This API uses a promise to return the result.
```js ```js
var subscriber; // Subscriber object successfully created. var subscriber; // Subscriber object successfully created.
subscriber.finishCommonEvent() subscriber.finishCommonEvent().then(() => {
.then(() => { console.info("FinishCommonEvent");
console.info("--------- finishCommonEventCallback ----------"); }).catch((err) => {
}) console.error("finishCommonEvent failed " + JSON.stringify(err));
});
``` ```
## CommonEventData ## CommonEventData
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册