| callback | AsyncCallback\<[CommonEventSubscriber](./js-apis-inner-commonEvent-commonEventSubscriber.md)> | Yes | Callback used to return the result.|
**Example**
...
...
@@ -236,12 +236,12 @@ Creates a subscriber. This API uses a promise to return the result.
Aborts this common event. After the abort, the common event is not sent to the next subscriber. This API takes effect only for ordered common events. It uses an asynchronous callback to return the result.
console.error(`abortCommonEvent failed, code is ${err.code}`);
}else{
console.info("abortCommonEvent");
}
}
subscriber.abortCommonEvent(abortCB);
```
### abortCommonEvent
```ts
abortCommonEvent():Promise<void>
```
Aborts this common event. After the abort, the common event is not sent to the next subscriber. This API takes effect only for ordered common events. It uses a promise to return the result.
Clears the aborted state of this common event. This API takes effect only for ordered common events. It uses an asynchronous callback to return the result.
Checks whether this common event is in the aborted state. This API takes effect only for ordered common events. It uses an asynchronous callback to return the result.
// Callback for checking whether the current common event is in the aborted state.
functiongetAbortCB(err,abortEvent){
if(err.code){
console.error(`getAbortCommonEvent failed, code is ${err.code}`);
}else{
console.info("abortEvent "+abortEvent)
}
}
subscriber.getAbortCommonEvent(getAbortCB);
```
### getAbortCommonEvent
```ts
getAbortCommonEvent():Promise<boolean>
```
Checks whether this common event is in the aborted state. This API takes effect only for ordered common events. It uses a promise to return the result.
| code | number | Yes | No | Result code of the common event. |
| data | string | Yes | No | Custom result data of the common event.|
| subscriberPermissions | Array\<string\> | Yes | No | Permissions required for subscribers to receive the common event. |
| isOrdered | boolean | Yes | No | Whether the common event is an ordered one. |
| isSticky | boolean | Yes | No | Whether the common event is a sticky one. Only system applications and system services are allowed to send sticky events.|
| parameters | {[key: string]: any} | Yes | No | Additional information about the common event. |
| events | Array\<string\> | Yes | No | Name of the common event to publish. |
| publisherPermission | string | Yes | No | Permissions required for publishers to publish the common event. |
| publisherDeviceId | string | Yes | No | Device ID. The value must be the ID of an existing device on the same network. |
| userId | number | Yes | No | User ID. The default value is the ID of the current user. If this parameter is specified, the value must be an existing user ID in the system.|
| priority | number | Yes | No | Subscriber priority. The value ranges from -100 to +1000. |
| callback | AsyncCallback\<[CommonEventSubscriber](./js-apis-inner-commonEvent-commonEventSubscriber.md)> | Yes | Callback used to return the result.|
**Example**
...
...
@@ -270,12 +270,12 @@ Creates a subscriber. This API uses a promise to return the result.
| callback | AsyncCallback\<boolean> | Yes | Callback used to return the result. The value **true** means that the common event is an ordered one; and **false** means the opposite.|
| Promise\<boolean> | Promise used to return the result. The value **true** means that the common event is an ordered one; and **false** means the opposite.|
| callback | AsyncCallback\<boolean> | Yes | Callback used to return the result. The value **true** means that the common event is a sticky one; and **false** means the opposite.|
| Promise\<boolean> | Promise used to return the result. The value **true** means that the common event is a sticky one; and **false** means the opposite.|
Aborts this common event. After the abort, the common event is not sent to the next subscriber. This API takes effect only for ordered common events. It uses an asynchronous callback to return the result.
console.error(`abortCommonEvent failed, code is ${err.code}, message is ${err.message}`);
}else{
console.info("abortCommonEvent");
}
}
subscriber.abortCommonEvent(abortCB);
```
### abortCommonEvent
```ts
abortCommonEvent():Promise<void>
```
Aborts this common event. After the abort, the common event is not sent to the next subscriber. This API takes effect only for ordered common events. It uses a promise to return the result.
Clears the aborted state of this common event. This API takes effect only for ordered common events. It uses an asynchronous callback to return the result.
Checks whether this common event is in the aborted state. This API takes effect only for ordered common events. It uses an asynchronous callback to return the result.
| callback | AsyncCallback\<boolean> | Yes | Callback used to return the result. The value **true** means that the ordered common event is in the aborted state; and **false** means the opposite.|
// Callback for checking whether the current common event is in the aborted state.
functiongetAbortCB(err,abortEvent){
if(err.code){
console.error(`getAbortCommonEvent failed, code is ${err.code}, message is ${err.message}`);
}else{
console.info("abortCommonEvent "+abortEvent)
}
}
subscriber.getAbortCommonEvent(getAbortCB);
```
### getAbortCommonEvent
```ts
getAbortCommonEvent():Promise<boolean>
```
Checks whether this common event is in the aborted state. This API takes effect only for ordered common events. It uses a promise to return the result.
| Promise\<boolean> | Promise used to return the result. The value **true** means that the ordered common event is in the aborted state; and **false** means the opposite.|
| code | number | Yes | No | Code of the common event. |
| data | string | Yes | No | Custom data of the common event.|
| subscriberPermissions | Array\<string> | Yes | No | Permissions required for subscribers to receive the common event. |
| isOrdered | boolean | Yes | No | Whether the common event is an ordered one. |
| isSticky | boolean | Yes | No | Whether the common event is a sticky one. Only system applications and system services are allowed to send sticky events.|
| parameters | {[key: string]: any} | Yes | No | Additional information about the common event. |
| events | Array\<string> | Yes | No | Name of the common event to publish. |
| publisherPermission | string | Yes | No | Permissions required for publishers to publish the common event. |
| publisherDeviceId | string | Yes | No | Device ID. The value must be the ID of an existing device on the same network. |
| userId | number | Yes | No | User ID. The default value is the ID of the current user. If this parameter is specified, the value must be an existing user ID in the system.|
| priority | number | Yes | No | Subscriber priority. The value ranges from -100 to +1000. |
| code | number | Yes | No | Result code of the common event. |
| data | string | Yes | No | Custom result data of the common event.|
| subscriberPermissions | Array\<string> | Yes | No | Permissions required for subscribers to receive the common event. |
| isOrdered | boolean | Yes | No | Whether the common event is an ordered one. |
| isSticky | boolean | Yes | No | Whether the common event is a sticky one. Only system applications and system services are allowed to send sticky events.|
| parameters | {[key: string]: any} | Yes | No | Additional information about the common event. |
| events | Array\<string> | Yes | No | Name of the common event to publish. |
| publisherPermission | string | Yes | No | Permissions required for publishers to publish the common event. |
| publisherDeviceId | string | Yes | No | Device ID. The value must be the ID of a device on the same network. |
| userId | number | Yes | No | User ID. The value must be an existing user ID in the system. If this parameter is not specified, the default value, which is the ID of the current user, will be used. |
| priority | number | Yes | No | Subscriber priority. The value ranges from –100 to +1000. |
Aborts this common event. After the abort, the common event is not sent to the next subscriber. This API takes effect only for ordered common events. It uses an asynchronous callback to return the result.
console.error(`abortCommonEvent failed, code is ${err.code}, message is ${err.message}`);
}else{
console.info("abortCommonEvent");
}
}
subscriber.abortCommonEvent(abortCB);
```
## abortCommonEvent
```ts
abortCommonEvent():Promise<void>
```
Aborts this common event. After the abort, the common event is not sent to the next subscriber. This API takes effect only for ordered common events. It uses a promise to return the result.
Clears the aborted state of this common event. This API takes effect only for ordered common events. It uses an asynchronous callback to return the result.
Checks whether this common event is in the aborted state. This API takes effect only for ordered common events. It uses an asynchronous callback to return the result.
// Callback for checking whether the current common event is in the aborted state.
functiongetAbortCB(err,abortEvent){
if(err.code){
console.error(`getAbortCommonEvent failed, code is ${err.code}, message is ${err.message}`);
}else{
console.info("abortCommonEvent "+abortEvent)
}
}
subscriber.getAbortCommonEvent(getAbortCB);
```
## getAbortCommonEvent
```ts
getAbortCommonEvent():Promise<boolean>
```
Checks whether this common event is in the aborted state. This API takes effect only for ordered common events. It uses a promise to return the result.
| callback | AsyncCallback\<[CommonEventSubscribeInfo](./js-apis-inner-commonEvent-commonEventSubscribeInfo.md)> | Yes | Callback used to return the subscriber information.|