| write(string eventName, EventType type, object keyValues, AsyncCallback\<void> callback): void | Logs application events in asynchronous mode. This API uses an asynchronous callback to return the result. |
| write(string eventName, EventType type, object keyValues): Promise\<void> | Logs application events in asynchronous mode. This API uses a promise to return the result. |
| write(AppEventInfo info, AsyncCallback\<void> callback): void | Logs application events by domain in asynchronous mode. This API uses an asynchronous callback to return the result.|
| write(AppEventInfo info): Promise\<void> | Logs application events by domain in asynchronous mode. This API uses a promise to return the result.|
| write(AppEventInfo info, AsyncCallback\<void> callback): void | Logs application events in asynchronous mode. This API uses an asynchronous callback to return the result.|
| write(AppEventInfo info): Promise\<void> | Logs application events in asynchronous mode. This API uses a promise to return the result. |
When an asynchronous callback is used, the return value can be processed directly in the callback.
...
...
@@ -84,6 +82,7 @@ The following uses a one-time event watcher as an example to illustrate the deve
.fontWeight(FontWeight.Bold)
Button("1 writeTest").onClick(()=>{
// Perform event logging based on the input event parameters.
hiAppEvent.write({
domain:"test_domain",
name:"test_event",
...
...
@@ -100,6 +99,7 @@ The following uses a one-time event watcher as an example to illustrate the deve
})
Button("2 addWatcherTest").onClick(()=>{
// Add an event watcher based on the input subscription parameters.
hiAppEvent.addWatcher({
name:"watcher1",
appEventFilters:[{domain:"test_domain"}],
...
...
@@ -109,17 +109,23 @@ The following uses a one-time event watcher as an example to illustrate the deve
timeOut:2
},
onTrigger:function(curRow,curSize,holder){
// If the holder object is null, return an error after recording it in the log.
if(holder==null){
console.error("HiAppEvent holder is null");
return;
}
// Set the size threshold to 1,000 bytes for obtaining an event package.
holder.setSize(1000);
leteventPkg=null;
// Obtain the event package based on the configured size threshold. If returned event package is null, all event data has been obtained.
>The mapping between the development board and the building GUI:
> **NOTE**<br>
>The mapping between the development board and the building GUI:
>
>- Hi3861: wifiiot\_hispark\_pegasus@hisilicon
>- Hi3516: ipcamera\_hispark\_taurus@hisilicon
>- Hi3518: ipcamera\_hispark\_aries@hisilicon
>- Hi3861: wifiiot\_hispark\_pegasus@hisilicon
>- Hi3516: ipcamera\_hispark\_taurus@hisilicon
>- Hi3518: ipcamera\_hispark\_aries@hisilicon
1. Select **ipcamera\_hispark\_taurus@hisilicon** and press **Enter**.
1. Select **ipcamera\_hispark\_taurus@hisilicon** and press**Enter**.
2. Start building.
```
...
...
@@ -130,7 +131,7 @@ hb set
3. View the build result.
The files will be generated in the **out/hispark\_taurus/ipcamera\_hispark\_taurus** directory.
The files will be generated in the **out/hispark\_taurus/ipcamera\_hispark\_taurus** directory.
### Setting Up the Docker Environment for Standard-System Devices \(reference memory ≥ 128 MB\)<a name="section13585262391"></a>
...
...
@@ -156,17 +157,17 @@ Run the following script to start building for standard-system devices \(referen
./build.sh --product-name {product_name} --ccache
```
**product\_name**indicates the platform supported by the current distribution, for example, hispark_taurus_standard and rk3568.
**product\_name** indicates the platform supported by the current distribution, for example, hispark_taurus_standard and rk3568.
Files generated during building are stored in the **out/{device_name}/** directory, and the generated image is stored in the **out/{device_name}/packages/phone/images/** directory.
Files generated during building are stored in the **out/{device_name}/** directory, and the generated image is stored in the **out/{device_name}/packages/phone/images/** directory.
**docker\_dist**is a template component in the [HPM](https://hpm.harmonyos.com/#/en/home) system. It helps to quickly initialize an HPM project and use the Docker image to quickly build a distribution of OpenHarmony, greatly simplifying environment configurations needed for building. After configuring the Ubuntu and hpm-cli development environments, perform the following steps to access the Docker environment:
**docker\_dist** is a template component in the [HPM](https://hpm.harmonyos.com/#/en/home) system. It helps to quickly initialize an HPM project and use the Docker image to quickly build a distribution of OpenHarmony, greatly simplifying environment configurations needed for building. After configuring the Ubuntu and hpm-cli development environments, perform the following steps to access the Docker environment:
### Setting Up the Docker Environment<a name="section3295842510"></a>
...
...
@@ -176,20 +177,20 @@ Files generated during building are stored in the **out/{device_name}/** direc
hpm init -t @ohos/docker_dist
```
2. Modify the **publishAs** field.
2. Modify the **publishAs** field.
The obtained bundle is of the template type. Open the **bundle.json** file in the current directory and change the value of **publishAs** from **template** to **distribution** as needed.
The obtained bundle is of the template type. Open the **bundle.json** file in the current directory and change the value of **publishAs** from **template** to **distribution** as needed.
### Obtaining and Building Source Code<a name="section69141039143518"></a>
Start building. Docker can be automatically installed only in Ubuntu. If you are using any other operating system, manually install Docker before pulling the image.
-**Automatically Installing Docker \(Ubuntu\)**
-**Automatically Installing Docker \(Ubuntu\)**
Running the following command will automatically install Docker, pull the Docker image, and start the pulling and building of the corresponding solution in the container.
**Method 1:**
**Method 1:**
Add a parameter to specify the solution. For example:
...
...
@@ -197,9 +198,9 @@ Start building. Docker can be automatically installed only in Ubuntu. If you are
hpm run docker solution={product}
```
**\{product\}** indicates the solution, for example, **@ohos/hispark\_taurus**, **@ohos/hispark\_aries**, and **@ohos/hispark\_pegasus**.
**\{product\}** indicates the solution, for example, **@ohos/hispark\_taurus**, **@ohos/hispark\_aries**, and**@ohos/hispark\_pegasus**.
**Method 2:**
**Method 2:**
Set an environment variable to specify the solution, and then run the build command.
...
...
@@ -209,7 +210,7 @@ Start building. Docker can be automatically installed only in Ubuntu. If you are
export solution={product}
```
**\{product\}** indicates the solution, for example, **@ohos/hispark\_taurus**, **@ohos/hispark\_aries**, and **@ohos/hispark\_pegasus**.
**\{product\}** indicates the solution, for example, **@ohos/hispark\_taurus**, **@ohos/hispark\_aries**, and **@ohos/hispark\_pegasus**.
2. Obtain and build the source code.
...
...
@@ -217,7 +218,7 @@ Start building. Docker can be automatically installed only in Ubuntu. If you are
hpm run docker
```
This example uses the **@ohos/hispark\_taurus** solution for illustration. If the execution is successful, the output is as follows:
This example uses the **@ohos/hispark\_taurus** solution for illustration. If the execution is successful, the output is as follows:
```
...
...
...
@@ -226,7 +227,7 @@ Start building. Docker can be automatically installed only in Ubuntu. If you are
```
-**Manually Installing Docker \(Non-Ubuntu\)**
-**Manually Installing Docker \(Non-Ubuntu\)**
Perform the following operations to install Docker: