Summary
This ticket tracks the architectural refactoring to create a new common base class, Neo.component.Abstract, for both classic (Neo.component.Base) and functional (Neo.functional.component.Base) components.
Motivation
The component architecture previously had two separate base classes that, while using mixins, still contained a significant amount of duplicated code for lifecycle management, configuration, and core properties. This duplication increased maintenance overhead and made it difficult to ensure consistent behavior between the two component models.
By creating a shared Abstract base class, we achieve:
- Improved Code Reusability: Centralizes common logic (e.g.,
set(), destroy(), mountedPromise, core configs) in one place, following the DRY (Don't Repeat Yourself) principle.
- Enhanced Consistency: Guarantees that both classic and functional components share the exact same foundational implementation for core functionalities.
- Simplified Maintenance: Changes to the core component lifecycle only need to be made in one location.
- Future-Proofing: Provides a unified foundation to more easily add shared features, such as state provider and view controller support, to functional components in the future.
Scope
Create src/component/Abstract.mjs:
- A new base class that extends
Neo.core.Base.
- It incorporates the
DomEvents, Observable, and VdomLifecycle mixins.
- It contains the shared configs, properties, getters, and methods previously duplicated in both component base classes.
Refactor src/component/Base.mjs:
- Change its
extends clause from Neo.core.Base to Neo.component.Abstract.
- Remove all code that was moved into the new abstract class.
Refactor src/functional/component/Base.mjs:
- Change its
extends clause from Neo.core.Base to Neo.component.Abstract.
- Remove all code that was moved into the new abstract class.
Acceptance Criteria
- The file
src/component/Abstract.mjs is created and implemented as described.
Neo.component.Base now extends Neo.component.Abstract.
Neo.functional.component.Base now extends Neo.component.Abstract.
- Duplicated code has been removed from both child base classes.
- All existing component-related tests continue to pass, verifying that the refactoring did not introduce regressions.
Summary
This ticket tracks the architectural refactoring to create a new common base class,
Neo.component.Abstract, for both classic (Neo.component.Base) and functional (Neo.functional.component.Base) components.Motivation
The component architecture previously had two separate base classes that, while using mixins, still contained a significant amount of duplicated code for lifecycle management, configuration, and core properties. This duplication increased maintenance overhead and made it difficult to ensure consistent behavior between the two component models.
By creating a shared
Abstractbase class, we achieve:set(),destroy(),mountedPromise, core configs) in one place, following the DRY (Don't Repeat Yourself) principle.Scope
Create
src/component/Abstract.mjs:Neo.core.Base.DomEvents,Observable, andVdomLifecyclemixins.Refactor
src/component/Base.mjs:extendsclause fromNeo.core.BasetoNeo.component.Abstract.Refactor
src/functional/component/Base.mjs:extendsclause fromNeo.core.BasetoNeo.component.Abstract.Acceptance Criteria
src/component/Abstract.mjsis created and implemented as described.Neo.component.Basenow extendsNeo.component.Abstract.Neo.functional.component.Basenow extendsNeo.component.Abstract.