• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Lifecycle
2
3
4## Application Lifecycle
5
6You can define the following application lifecycle functions in the app.js file.
7
8  | Attribute | Type | Description | Called When |
9| -------- | -------- | -------- | -------- |
10| onCreate | () => void | Listens for application creation. | The application is created. |
11| onShow<sup>6+</sup> | () => void | Listens for whether the application is running in the foreground. | The application is running in the foreground. |
12| onHide<sup>6+</sup> | () => void | Listens for whether the application is running in the background. | The application is running in the background. |
13| onDestroy | () => void | Listens for application uninstallation. | The application exits. |
14
15## Page Lifecycle
16
17You can define the following page lifecycle functions in the .js file of the page.
18
19| Attribute | Type | Description | Called When |
20| -------- | -------- | -------- | -------- |
21| onInit | () => void | Listens for page initialization. | Page initialization is complete. This function is called only once in the page lifecycle. |
22| onReady | () => void | Listens for page creation. | A page is created. This function is called only once in the page lifecycle. |
23| onShow | () => void | Listens for page display. | The page is displayed. |
24| onHide | () => void | Listens for page disappearance. | The page disappears. |
25| onDestroy | () => void | Listens for page destruction. | The page is destroyed. |
26| onBackPress | () => boolean | Listens for the back button action. | The back button is touched.<br/>- true means that the page processes the return logic.<br/>- false means that the default return logic is used.<br/>- If no value is returned, the default return logic is used. |
27| onActive()<sup>5+</sup> | () => void | Listens for page activation. | The page is activated. |
28| onInactive()<sup>5+</sup> | () => void | Listens for page suspension. | The page is suspended. |
29| onNewRequest()<sup>5+</sup> | () => void | Listens for a new FA request. | The FA has been started and a new request is received. |
30
31 The lifecycle functions of page A are called in the following sequence:
32- Open page A: onInit() -> onReady() -> onShow()
33
34- Open page B on page A: onHide()
35
36- Go back to page A from page B: onShow()
37
38- Exit page A: onBackPress() -> onHide() -> onDestroy()
39
40- Hide page A: onInactive() -> onHide()
41
42- Show background page A on the foreground: onShow() -> onActive()
43
44![en-us_image_0000001267887881](figures/en-us_image_0000001267887881.png)
45
46