Control life cycle
The control life cycle describes which system function of the control is called by the system at which time. In the control life cycle, a distinction is made as to whether the control is on an HMI page for which preloading is activated.
The base control life cycle is described in the following diagram:
Explanations:
- The constructor is called during control instantiation.
- The PrevInit function is called after the constructor and before the attribute setter functions are called.
- The attribute setter functions are called after the PrevInit function.
- The init function is called after the attribute setter functions. At this point, the control attributes are initialized by the attribute setter functions and have valid values.
- The Attach function is called after the Init function, once the control has been added to the DOM on the HMI page.
- The Detach function is called after a control has been removed from the DOM of the HMI page (e.g. during page switching).
- The Destroy function is called after the control has been removed from the DOM of the HMI page, so that the system can destroy the controls. In addition, the Destroy function can be called explicitly at another point (for example, when subordinate controls elements are destroyed).
HMI page: Preloading disabled
Normally, preloading of an HMI page is disabled (Preload this partial: false), which means that the controls are not stored in the browser cache. This increases the speed of the initial HMI loading process, but it can lead to a reduction in the loading speed of individual HMI pages on which many controls are instantiated.
In this case, the constructor of the control is called when the page is loaded (for example, when switching to the page or when loading the start page). This is followed by the PrevInit function, the attribute setter functions, the Init function and the Attach function. As soon as the page is unloaded (e.g. when switching to another page), the Detach function is called, followed by the Destroy function. The life cycle of the controls starts again when the HMI page is loaded.
HMI page: Preloading enabled
If preloading is enabled for an HMI page (preload this partial: true), the controls are stored in the browser cache. This increases the loading speed of a single HMI page, but it can lead to a reduction in the initial loading process of the HMI.
In this case, the constructor of the control is called as soon as the HMI is initially loaded. This is followed by the PrevInit function, the attribute setter functions and the init function. The Attach function of the control is not called until the HMI page on which the control is instantiated is loaded. The Detach function is called as soon as the HMI page is unloaded. The Destroy function is not called automatically subsequently. The control remains in the browser cache. When the HMI page is reloaded, the Attach function is called directly.