new Base_A(propsopt)
Base class for handling objects
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
props | object | <optional> | {} | Initial properties for the object |
- Source
Will throw an error if props is not an object
const baseInstance = new TComponents.Base_A({prop1: 'value1', prop2: 42});
baseInstance.on('event1', (data) => {
console.log('Event 1 triggered with data:', data);
});Extends
Members
props :object
The properties of the component.
- object
- Source
const base = new TComponents.Base_A();
base.props = { key: 'value' };Methods
commitProps(newProps) → {object}
Updates the component properties using the internal merge logic and synchronizes the previous properties snapshot.
This method applies the given properties directly to the internal _props object without triggering the component update lifecycle (init() or render()).
After the update, _prevProps is synchronized with the new _props, establishing a new baseline state for future change detection.
⚠️ This method should be used only for internal or controlled updates. To trigger a normal component update flow, use TComponents.Base_A#setProps.
| Name | Type | Description |
|---|---|---|
newProps | object | Object containing the properties to update. |
- Source
An object containing the updated properties and a flag indicating whether any property value changed.
- Type:
- object
(protected) defaultProps() → {object}
Returns an object with expected input properties together with their initial value. Every child class shall have a TComponents.Base_A#defaultProps to register its corresponding input properties.
- Source
- Type:
- object
class MyComponent extends TComponents.Component_A {
constructor(parent, props){}
defaultProps(){
return {
myProp1: '',
myProp2: 0,
myProp3: false,
myProp4: { a: 'A', b: 'B'}
}
}
}getProps() → {object}
Returns a copy of the component properties. Notice that the returning value does not have a reference to the internal properties of the component. i.e. changing a value in that object does not affect the component itself. To change the properties of the component use the TComponent.Base_A#setProps method.
- Source
- Type:
- object
(async, abstract, protected) init() → {Promise.<object>}
Abstract function for asynchronous initialization of the component. This function is overwritten in TComponents.Component_A
- Source
The TComponents instance on which this method was called.
- Type:
- Promise.<object>
(protected) initPropsDep(props)
Register the properties that trigger an onInit when changed with setProps(). Input value is a string or array of strings with the name of the corresponding props
| Name | Type | Description |
|---|---|---|
props | string | | The properties that trigger an onInit when changed |
- Source
Will throw an error if the new value is not a string or an array of strings
this.initPropsDep(['module', 'variable']);initPropsDep(newProps, onRenderopt, syncopt, forceopt) → {Promise.<boolean>}
Method used to update one or multiple component input properties. A change of property using this method will trigger at least a TComponent.Base_A#render() call. If at least one of the given properties is listed in the TComponent.Base_A#initPropsDep array, then a TComponent.Base_A#init() is called before the TComponent.Base_A#render().
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
newProps | object | Object including the property or properties to be updated. | ||
onRender | function | | <optional> | null | Function to be executed once after the component has been rendered. |
sync | boolean | <optional> | false | Whether to update synchronously or not |
force | boolean | <optional> | false | Whether to force the update or not |
- Source
- true if the component has been updated, false otherwise
- Type:
- Promise.<boolean>
(async, abstract, protected) render()
Abstract function for DOM rendering. This function is overwritten in TComponents.Component_A
- Source