TComponents. Base_A

new Base_A(propsopt)

Base class for handling objects

Parameters:
NameTypeAttributesDefaultDescription
propsobject<optional>
{}

Initial properties for the object

Throws:

Will throw an error if props is not an object

Example
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.

Type:
  • object
Example
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.

Parameters:
NameTypeDescription
newPropsobject

Object containing the properties to update.

Returns:

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.

Returns:
Type: 
object
Example
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.

Returns:
Type: 
object

(async, abstract, protected) init() → {Promise.<object>}

Abstract function for asynchronous initialization of the component. This function is overwritten in TComponents.Component_A

Returns:

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

Parameters:
NameTypeDescription
propsstring | Array.<string>

The properties that trigger an onInit when changed

Throws:

Will throw an error if the new value is not a string or an array of strings

Example
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().

Parameters:
NameTypeAttributesDefaultDescription
newPropsobject

Object including the property or properties to be updated.

onRenderfunction | null<optional>
null

Function to be executed once after the component has been rendered.

syncboolean<optional>
false

Whether to update synchronously or not

forceboolean<optional>
false

Whether to force the update or not

Returns:
  • 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