๐ Component Lifecycle in KIMU-CORE โ
Understanding the lifecycle of a component is essential for building robust and maintainable extensions and UI elements in KIMU-CORE.
Lifecycle Phases โ
Creation
- The component is instantiated and its constructor is called.
- Initial properties and state are set.
Initialization
- Lifecycle hooks (e.g.,
onInit,connectedCallback) are triggered. - The component is registered and ready to interact with other parts of the system.
- Lifecycle hooks (e.g.,
Rendering
- The component's template is rendered to the DOM.
- Any dynamic data or bindings are applied.
Update
- When state or properties change, the component re-renders or updates only the affected parts.
- Hooks like
onUpdateorattributeChangedCallbackmay be called.
Destruction
- When the component is removed from the DOM, cleanup hooks (e.g.,
onDestroy,disconnectedCallback) are called. - Resources, listeners, and timers are released.
- When the component is removed from the DOM, cleanup hooks (e.g.,
Example Lifecycle Hooks โ
typescript
class MyComponent extends KimuComponentElement {
constructor() {
super();
// Initialization logic
}
connectedCallback() {
super.connectedCallback();
// Called when added to the DOM