1e41f4b71Sopenharmony_ci# ComponentContent
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ci**ComponentContent** represents an entity encapsulation of component content, which can be created and transmitted outside of UI components. It allows you to encapsulate and decouple dialog box components. The underlying implementation of **ComponentContent** uses BuilderNode. For details, see [BuilderNode](js-apis-arkui-builderNode.md).
4e41f4b71Sopenharmony_ci
5e41f4b71Sopenharmony_ci> **NOTE**
6e41f4b71Sopenharmony_ci>
7e41f4b71Sopenharmony_ci> The initial APIs of this module are supported since API version 12. Newly added APIs will be marked with a superscript to indicate their earliest API version.
8e41f4b71Sopenharmony_ci> 
9e41f4b71Sopenharmony_ci> **ComponentContent** is not available in DevEco Studio Previewer.
10e41f4b71Sopenharmony_ci
11e41f4b71Sopenharmony_ci
12e41f4b71Sopenharmony_ci## Modules to Import
13e41f4b71Sopenharmony_ci
14e41f4b71Sopenharmony_ci```ts
15e41f4b71Sopenharmony_ciimport { ComponentContent } from '@kit.ArkUI';
16e41f4b71Sopenharmony_ci```
17e41f4b71Sopenharmony_ci
18e41f4b71Sopenharmony_ci## ComponentContent
19e41f4b71Sopenharmony_ci
20e41f4b71Sopenharmony_ci### constructor
21e41f4b71Sopenharmony_ci
22e41f4b71Sopenharmony_ciconstructor(uiContext: UIContext, builder: WrappedBuilder<[]>)
23e41f4b71Sopenharmony_ci
24e41f4b71Sopenharmony_ciA constructor used to create a **ComponentContent** object.
25e41f4b71Sopenharmony_ci
26e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12.
27e41f4b71Sopenharmony_ci
28e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
29e41f4b71Sopenharmony_ci
30e41f4b71Sopenharmony_ci**Parameters**
31e41f4b71Sopenharmony_ci
32e41f4b71Sopenharmony_ci| Name   | Type                                     | Mandatory | Description                              |
33e41f4b71Sopenharmony_ci| --------- | ----------------------------------------- | ---- | ---------------------------------- |
34e41f4b71Sopenharmony_ci| uiContext | [UIContext](./js-apis-arkui-UIContext.md) | Yes  | UI context required for creating the node. |
35e41f4b71Sopenharmony_ci| builder  | [WrappedBuilder<[]>](../../quick-start/arkts-wrapBuilder.md) | Yes  |   **WrappedBuilder** object that encapsulates a builder function that has no parameters. |
36e41f4b71Sopenharmony_ci
37e41f4b71Sopenharmony_ci### constructor
38e41f4b71Sopenharmony_ci
39e41f4b71Sopenharmony_ciconstructor(uiContext: UIContext, builder: WrappedBuilder<[T]>, args: T)
40e41f4b71Sopenharmony_ci
41e41f4b71Sopenharmony_ciA constructor used to create a **ComponentContent** object.
42e41f4b71Sopenharmony_ci
43e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12.
44e41f4b71Sopenharmony_ci
45e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
46e41f4b71Sopenharmony_ci
47e41f4b71Sopenharmony_ci**Parameters**
48e41f4b71Sopenharmony_ci
49e41f4b71Sopenharmony_ci| Name   | Type                                     | Mandatory | Description                              |
50e41f4b71Sopenharmony_ci| --------- | ----------------------------------------- | ---- | ---------------------------------- |
51e41f4b71Sopenharmony_ci| uiContext | [UIContext](./js-apis-arkui-UIContext.md) | Yes  | UI context required for creating the node. |
52e41f4b71Sopenharmony_ci| builder  | [WrappedBuilder<[T]>](../../quick-start/arkts-wrapBuilder.md) | Yes  |   **WrappedBuilder** object that encapsulates a builder function that has parameters. |
53e41f4b71Sopenharmony_ci| args     |     T     |   Yes  |   Parameters of the builder function encapsulated in the **WrappedBuilder** object. |
54e41f4b71Sopenharmony_ci
55e41f4b71Sopenharmony_ci### update
56e41f4b71Sopenharmony_ci
57e41f4b71Sopenharmony_ciupdate(args: T): void
58e41f4b71Sopenharmony_ci
59e41f4b71Sopenharmony_ciUpdates the parameters of the builder function encapsulated in the **WrappedBuilder** object. The parameter type must be the same as that passed in **constructor**.
60e41f4b71Sopenharmony_ci
61e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12.
62e41f4b71Sopenharmony_ci
63e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
64e41f4b71Sopenharmony_ci
65e41f4b71Sopenharmony_ci**Parameters**
66e41f4b71Sopenharmony_ci
67e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description                                                        |
68e41f4b71Sopenharmony_ci| ------ | ---- | ---- | ------------------------------------------------------------ |
69e41f4b71Sopenharmony_ci| args   | T    | Yes  | Parameters of the builder function encapsulated in the **WrappedBuilder** object. The parameter type must be the same as that passed in **constructor**. |
70e41f4b71Sopenharmony_ci
71e41f4b71Sopenharmony_ci**Example**
72e41f4b71Sopenharmony_ci
73e41f4b71Sopenharmony_ci```ts
74e41f4b71Sopenharmony_ciimport { ComponentContent } from "@kit.ArkUI";
75e41f4b71Sopenharmony_ci
76e41f4b71Sopenharmony_ciclass Params {
77e41f4b71Sopenharmony_ci  text: string = ""
78e41f4b71Sopenharmony_ci  constructor(text: string) {
79e41f4b71Sopenharmony_ci    this.text = text;
80e41f4b71Sopenharmony_ci  }
81e41f4b71Sopenharmony_ci}
82e41f4b71Sopenharmony_ci
83e41f4b71Sopenharmony_ci@Builder
84e41f4b71Sopenharmony_cifunction buildText(params: Params) {
85e41f4b71Sopenharmony_ci  Column() {
86e41f4b71Sopenharmony_ci    Text(params.text)
87e41f4b71Sopenharmony_ci      .fontSize(50)
88e41f4b71Sopenharmony_ci      .fontWeight(FontWeight.Bold)
89e41f4b71Sopenharmony_ci      .margin({bottom: 36})
90e41f4b71Sopenharmony_ci  }.backgroundColor('#FFF0F0F0')
91e41f4b71Sopenharmony_ci}
92e41f4b71Sopenharmony_ci
93e41f4b71Sopenharmony_ci@Entry
94e41f4b71Sopenharmony_ci@Component
95e41f4b71Sopenharmony_cistruct Index {
96e41f4b71Sopenharmony_ci  @State message: string = "hello"
97e41f4b71Sopenharmony_ci
98e41f4b71Sopenharmony_ci  build() {
99e41f4b71Sopenharmony_ci    Row() {
100e41f4b71Sopenharmony_ci      Column() {
101e41f4b71Sopenharmony_ci        Button("click me")
102e41f4b71Sopenharmony_ci            .onClick(() => {
103e41f4b71Sopenharmony_ci                let uiContext = this.getUIContext();
104e41f4b71Sopenharmony_ci                let promptAction = uiContext.getPromptAction();
105e41f4b71Sopenharmony_ci                let contentNode = new ComponentContent(uiContext, wrapBuilder(buildText), new Params(this.message));
106e41f4b71Sopenharmony_ci                promptAction.openCustomDialog(contentNode);
107e41f4b71Sopenharmony_ci
108e41f4b71Sopenharmony_ci                setTimeout(() => {
109e41f4b71Sopenharmony_ci                  contentNode.update(new Params("new message"));
110e41f4b71Sopenharmony_ci                }, 2000);    // Automatically update the text in the dialog box after 2 seconds.
111e41f4b71Sopenharmony_ci            })
112e41f4b71Sopenharmony_ci      }
113e41f4b71Sopenharmony_ci      .width('100%')
114e41f4b71Sopenharmony_ci      .height('100%')
115e41f4b71Sopenharmony_ci    }
116e41f4b71Sopenharmony_ci    .height('100%')
117e41f4b71Sopenharmony_ci  }
118e41f4b71Sopenharmony_ci}
119e41f4b71Sopenharmony_ci```
120e41f4b71Sopenharmony_ci
121e41f4b71Sopenharmony_ci### reuse
122e41f4b71Sopenharmony_ci
123e41f4b71Sopenharmony_cireuse(param?: Object): void
124e41f4b71Sopenharmony_ci
125e41f4b71Sopenharmony_ciPasses the reuse event to the custom component in this **ComponentContent** object.
126e41f4b71Sopenharmony_ci
127e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12.
128e41f4b71Sopenharmony_ci
129e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
130e41f4b71Sopenharmony_ci
131e41f4b71Sopenharmony_ci**Parameters**
132e41f4b71Sopenharmony_ci
133e41f4b71Sopenharmony_ci| Name | Type  | Mandatory | Description                                                                    |
134e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ------------------------------------------------------------------------ |
135e41f4b71Sopenharmony_ci| param  | Object | No  | Parameters of the builder function encapsulated in the **WrappedBuilder** object. The parameter type must be the same as that passed in **constructor**. |
136e41f4b71Sopenharmony_ci
137e41f4b71Sopenharmony_ci### recycle
138e41f4b71Sopenharmony_ci
139e41f4b71Sopenharmony_cirecycle(): void
140e41f4b71Sopenharmony_ci
141e41f4b71Sopenharmony_ciPasses the recycle event to the custom component in this **ComponentContent** object.
142e41f4b71Sopenharmony_ci
143e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12.
144e41f4b71Sopenharmony_ci
145e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
146e41f4b71Sopenharmony_ci
147e41f4b71Sopenharmony_ci```ts
148e41f4b71Sopenharmony_ciimport { ComponentContent } from '@kit.ArkUI';
149e41f4b71Sopenharmony_ci
150e41f4b71Sopenharmony_ciclass Params {
151e41f4b71Sopenharmony_ci  text: string = ""
152e41f4b71Sopenharmony_ci
153e41f4b71Sopenharmony_ci  constructor(text: string) {
154e41f4b71Sopenharmony_ci    this.text = text;
155e41f4b71Sopenharmony_ci  }
156e41f4b71Sopenharmony_ci}
157e41f4b71Sopenharmony_ci
158e41f4b71Sopenharmony_ci@Builder
159e41f4b71Sopenharmony_cifunction buildText(params: Params) {
160e41f4b71Sopenharmony_ci  ReusableChildComponent2({ text: params.text });
161e41f4b71Sopenharmony_ci}
162e41f4b71Sopenharmony_ci
163e41f4b71Sopenharmony_ci@Component
164e41f4b71Sopenharmony_cistruct ReusableChildComponent2 {
165e41f4b71Sopenharmony_ci  @Prop text: string = "false";
166e41f4b71Sopenharmony_ci
167e41f4b71Sopenharmony_ci  aboutToReuse(params: Record<string, object>) {
168e41f4b71Sopenharmony_ci    console.log("ReusableChildComponent2 Reusable " + JSON.stringify(params));
169e41f4b71Sopenharmony_ci  }
170e41f4b71Sopenharmony_ci
171e41f4b71Sopenharmony_ci  aboutToRecycle(): void {
172e41f4b71Sopenharmony_ci    console.log("ReusableChildComponent2 aboutToRecycle " + this.text);
173e41f4b71Sopenharmony_ci  }
174e41f4b71Sopenharmony_ci
175e41f4b71Sopenharmony_ci  build() {
176e41f4b71Sopenharmony_ci    Column() {
177e41f4b71Sopenharmony_ci      Text(this.text)
178e41f4b71Sopenharmony_ci        .fontSize(50)
179e41f4b71Sopenharmony_ci        .fontWeight(FontWeight.Bold)
180e41f4b71Sopenharmony_ci        .margin({ bottom: 36 })
181e41f4b71Sopenharmony_ci    }.backgroundColor('#FFF0F0F0')
182e41f4b71Sopenharmony_ci  }
183e41f4b71Sopenharmony_ci}
184e41f4b71Sopenharmony_ci
185e41f4b71Sopenharmony_ci@Entry
186e41f4b71Sopenharmony_ci@Component
187e41f4b71Sopenharmony_cistruct Index {
188e41f4b71Sopenharmony_ci  @State message: string = "hello"
189e41f4b71Sopenharmony_ci
190e41f4b71Sopenharmony_ci  build() {
191e41f4b71Sopenharmony_ci    Row() {
192e41f4b71Sopenharmony_ci      Column() {
193e41f4b71Sopenharmony_ci        Button("click me")
194e41f4b71Sopenharmony_ci          .onClick(() => {
195e41f4b71Sopenharmony_ci            let uiContext = this.getUIContext();
196e41f4b71Sopenharmony_ci            let promptAction = uiContext.getPromptAction();
197e41f4b71Sopenharmony_ci            let contentNode = new ComponentContent(uiContext, wrapBuilder(buildText), new Params(this.message));
198e41f4b71Sopenharmony_ci            promptAction.openCustomDialog(contentNode);
199e41f4b71Sopenharmony_ci
200e41f4b71Sopenharmony_ci            setTimeout(() => {
201e41f4b71Sopenharmony_ci              contentNode.reuse(new Params("new message"));
202e41f4b71Sopenharmony_ci              contentNode.recycle();
203e41f4b71Sopenharmony_ci            }, 2000); // Automatically update the text in the dialog box after 2 seconds.
204e41f4b71Sopenharmony_ci          })
205e41f4b71Sopenharmony_ci      }
206e41f4b71Sopenharmony_ci      .width('100%')
207e41f4b71Sopenharmony_ci      .height('100%')
208e41f4b71Sopenharmony_ci    }
209e41f4b71Sopenharmony_ci    .height('100%')
210e41f4b71Sopenharmony_ci  }
211e41f4b71Sopenharmony_ci}
212e41f4b71Sopenharmony_ci```
213e41f4b71Sopenharmony_ci
214e41f4b71Sopenharmony_ci### dispose
215e41f4b71Sopenharmony_ci
216e41f4b71Sopenharmony_cidispose(): void
217e41f4b71Sopenharmony_ci
218e41f4b71Sopenharmony_ciDisposes of this **ComponentContent** object, which means to cancel the reference relationship between the **ComponentContent** object and its backend entity node.
219e41f4b71Sopenharmony_ci
220e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12.
221e41f4b71Sopenharmony_ci
222e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
223e41f4b71Sopenharmony_ci
224e41f4b71Sopenharmony_ci**Example** 
225e41f4b71Sopenharmony_ci
226e41f4b71Sopenharmony_ci```ts
227e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
228e41f4b71Sopenharmony_ciimport { ComponentContent } from '@kit.ArkUI';
229e41f4b71Sopenharmony_ci
230e41f4b71Sopenharmony_ciclass Params {
231e41f4b71Sopenharmony_ci  text: string = ""
232e41f4b71Sopenharmony_ci  constructor(text: string) {
233e41f4b71Sopenharmony_ci    this.text = text;
234e41f4b71Sopenharmony_ci  }
235e41f4b71Sopenharmony_ci}
236e41f4b71Sopenharmony_ci
237e41f4b71Sopenharmony_ci@Builder
238e41f4b71Sopenharmony_cifunction buildText(params: Params) {
239e41f4b71Sopenharmony_ci  Column() {
240e41f4b71Sopenharmony_ci    Text(params.text)
241e41f4b71Sopenharmony_ci      .fontSize(50)
242e41f4b71Sopenharmony_ci      .fontWeight(FontWeight.Bold)
243e41f4b71Sopenharmony_ci      .margin({bottom: 36})
244e41f4b71Sopenharmony_ci  }.backgroundColor('#FFF0F0F0')
245e41f4b71Sopenharmony_ci}
246e41f4b71Sopenharmony_ci
247e41f4b71Sopenharmony_ci@Entry
248e41f4b71Sopenharmony_ci@Component
249e41f4b71Sopenharmony_cistruct Index {
250e41f4b71Sopenharmony_ci  @State message: string = "hello"
251e41f4b71Sopenharmony_ci
252e41f4b71Sopenharmony_ci  build() {
253e41f4b71Sopenharmony_ci    Row() {
254e41f4b71Sopenharmony_ci      Column() {
255e41f4b71Sopenharmony_ci        Button("click me")
256e41f4b71Sopenharmony_ci            .onClick(() => {
257e41f4b71Sopenharmony_ci                let uiContext = this.getUIContext();
258e41f4b71Sopenharmony_ci                let promptAction = uiContext.getPromptAction();
259e41f4b71Sopenharmony_ci                let contentNode = new ComponentContent(uiContext, wrapBuilder(buildText), new Params(this.message));
260e41f4b71Sopenharmony_ci                promptAction.openCustomDialog(contentNode);
261e41f4b71Sopenharmony_ci
262e41f4b71Sopenharmony_ci                setTimeout(() => {
263e41f4b71Sopenharmony_ci                  promptAction.closeCustomDialog(contentNode)
264e41f4b71Sopenharmony_ci                    .then(() => {
265e41f4b71Sopenharmony_ci                      console.info('customdialog closed.')
266e41f4b71Sopenharmony_ci                      if (contentNode !== null) {
267e41f4b71Sopenharmony_ci                        contentNode.dispose();   // Dispose of the contentNode object.
268e41f4b71Sopenharmony_ci                      }
269e41f4b71Sopenharmony_ci                    }).catch((error: BusinessError) => {
270e41f4b71Sopenharmony_ci                      let message = (error as BusinessError).message;
271e41f4b71Sopenharmony_ci                      let code = (error as BusinessError).code;
272e41f4b71Sopenharmony_ci                      console.error(`closeCustomDialog args error code is ${code}, message is ${message}`);
273e41f4b71Sopenharmony_ci                    })
274e41f4b71Sopenharmony_ci                }, 2000);     // Automatically close the dialog box after 2 seconds.
275e41f4b71Sopenharmony_ci            })
276e41f4b71Sopenharmony_ci      }
277e41f4b71Sopenharmony_ci      .width('100%')
278e41f4b71Sopenharmony_ci      .height('100%')
279e41f4b71Sopenharmony_ci    }
280e41f4b71Sopenharmony_ci    .height('100%')
281e41f4b71Sopenharmony_ci  }
282e41f4b71Sopenharmony_ci}
283e41f4b71Sopenharmony_ci```
284e41f4b71Sopenharmony_ci
285e41f4b71Sopenharmony_ci
286e41f4b71Sopenharmony_ci### updateConfiguration
287e41f4b71Sopenharmony_ci
288e41f4b71Sopenharmony_ciupdateConfiguration(): void
289e41f4b71Sopenharmony_ci
290e41f4b71Sopenharmony_ciUpdates the configuration of the entire node by passing in a [system environment change](../apis-ability-kit/js-apis-app-ability-configuration.md) event.
291e41f4b71Sopenharmony_ci
292e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12.
293e41f4b71Sopenharmony_ci
294e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
295e41f4b71Sopenharmony_ci
296e41f4b71Sopenharmony_ci> **NOTE**
297e41f4b71Sopenharmony_ci>
298e41f4b71Sopenharmony_ci> The **updateConfiguration** API is used to instruct an object to update itself. The update is based on the current changes in the system environment.
299e41f4b71Sopenharmony_ci
300e41f4b71Sopenharmony_ci**Example**
301e41f4b71Sopenharmony_ci```ts
302e41f4b71Sopenharmony_ciimport { NodeController, FrameNode, ComponentContent, typeNode } from '@kit.ArkUI';
303e41f4b71Sopenharmony_ciimport { AbilityConstant, Configuration, EnvironmentCallback } from '@kit.AbilityKit';
304e41f4b71Sopenharmony_ci
305e41f4b71Sopenharmony_ci@Builder
306e41f4b71Sopenharmony_cifunction buildText() {
307e41f4b71Sopenharmony_ci  Column() {
308e41f4b71Sopenharmony_ci    Text('hello')
309e41f4b71Sopenharmony_ci      .width(50)
310e41f4b71Sopenharmony_ci      .height(50)
311e41f4b71Sopenharmony_ci      .fontColor($r(`app.color.text_color`))
312e41f4b71Sopenharmony_ci  }.backgroundColor($r(`app.color.start_window_background`))
313e41f4b71Sopenharmony_ci}
314e41f4b71Sopenharmony_ci
315e41f4b71Sopenharmony_ciconst componentContentMap: Array<ComponentContent<[Object]>> = new Array();
316e41f4b71Sopenharmony_ci
317e41f4b71Sopenharmony_ciclass MyNodeController extends NodeController {
318e41f4b71Sopenharmony_ci  private rootNode: FrameNode | null = null;
319e41f4b71Sopenharmony_ci
320e41f4b71Sopenharmony_ci  makeNode(uiContext: UIContext): FrameNode | null {
321e41f4b71Sopenharmony_ci    return this.rootNode;
322e41f4b71Sopenharmony_ci  }
323e41f4b71Sopenharmony_ci
324e41f4b71Sopenharmony_ci  createNode(context: UIContext) {
325e41f4b71Sopenharmony_ci    this.rootNode = new FrameNode(context);
326e41f4b71Sopenharmony_ci    let component = new ComponentContent<Object>(context, wrapBuilder(buildText));
327e41f4b71Sopenharmony_ci    componentContentMap.push(component);
328e41f4b71Sopenharmony_ci    this.rootNode.addComponentContent(component);
329e41f4b71Sopenharmony_ci  }
330e41f4b71Sopenharmony_ci
331e41f4b71Sopenharmony_ci  deleteNode() {
332e41f4b71Sopenharmony_ci    let node = componentContentMap.pop();
333e41f4b71Sopenharmony_ci    this.rootNode?.dispose();
334e41f4b71Sopenharmony_ci    node?.dispose();
335e41f4b71Sopenharmony_ci  }
336e41f4b71Sopenharmony_ci}
337e41f4b71Sopenharmony_ci
338e41f4b71Sopenharmony_cifunction updateColorMode() {
339e41f4b71Sopenharmony_ci  componentContentMap.forEach((value, index) => {
340e41f4b71Sopenharmony_ci    value.updateConfiguration();
341e41f4b71Sopenharmony_ci  })
342e41f4b71Sopenharmony_ci}
343e41f4b71Sopenharmony_ci
344e41f4b71Sopenharmony_ci@Entry
345e41f4b71Sopenharmony_ci@Component
346e41f4b71Sopenharmony_cistruct FrameNodeTypeTest {
347e41f4b71Sopenharmony_ci  private myNodeController: MyNodeController = new MyNodeController();
348e41f4b71Sopenharmony_ci
349e41f4b71Sopenharmony_ci  aboutToAppear(): void {
350e41f4b71Sopenharmony_ci    let environmentCallback: EnvironmentCallback = {
351e41f4b71Sopenharmony_ci      onMemoryLevel: (level: AbilityConstant.MemoryLevel): void => {
352e41f4b71Sopenharmony_ci        console.log('onMemoryLevel');
353e41f4b71Sopenharmony_ci      },
354e41f4b71Sopenharmony_ci      onConfigurationUpdated: (config: Configuration): void => {
355e41f4b71Sopenharmony_ci        console.log('onConfigurationUpdated ' + JSON.stringify(config));
356e41f4b71Sopenharmony_ci        updateColorMode();
357e41f4b71Sopenharmony_ci      }
358e41f4b71Sopenharmony_ci    }
359e41f4b71Sopenharmony_ci    // Register a callback.
360e41f4b71Sopenharmony_ci    this.getUIContext().getHostContext()?.getApplicationContext().on('environment', environmentCallback);
361e41f4b71Sopenharmony_ci    this.myNodeController.createNode(this.getUIContext());
362e41f4b71Sopenharmony_ci  }
363e41f4b71Sopenharmony_ci
364e41f4b71Sopenharmony_ci  aboutToDisappear(): void {
365e41f4b71Sopenharmony_ci    // Remove the reference to the custom node from the map and release the node.
366e41f4b71Sopenharmony_ci    this.myNodeController.deleteNode();
367e41f4b71Sopenharmony_ci  }
368e41f4b71Sopenharmony_ci
369e41f4b71Sopenharmony_ci  build() {
370e41f4b71Sopenharmony_ci    Row() {
371e41f4b71Sopenharmony_ci      NodeContainer(this.myNodeController);
372e41f4b71Sopenharmony_ci    }
373e41f4b71Sopenharmony_ci  }
374e41f4b71Sopenharmony_ci}
375e41f4b71Sopenharmony_ci```
376