Currently, the Neo.mjs mixin system, implemented via applyMixins in src/Neo.mjs, effectively copies methods from mixins to the target class's prototype. However, it does not automatically merge the static config properties defined within mixins into the static config of the class that consumes them.
This behavior means that default configuration values or new configurable properties introduced by a mixin are not automatically inherited by the consuming class. Developers are required to manually replicate or merge these configurations, which introduces boilerplate, increases the risk of errors, and diminishes the "plug-and-play" benefit of mixins for configuration.
Proposed Enhancement:
Modify the applyMixins function (or the Neo.setupClass process where mixins are applied) to intelligently merge the static config of each applied mixin into the static config of the target class. This merge should respect the inheritance hierarchy, allowing the consuming class's own static config to override mixin configs, and later mixins to override earlier ones (or a defined merge strategy).
Benefits:
- Reduced Boilerplate: Eliminates the need for manual config merging in consuming classes.
- Improved Maintainability: Configuration defaults and new configurable properties introduced by mixins are automatically applied.
- Enhanced Developer Experience: Mixins become more powerful and intuitive for sharing not just behavior, but also configurable state.
- Consistency: Aligns the mixin system more closely with the declarative nature of Neo.mjs's config system.
Currently, the Neo.mjs mixin system, implemented via
applyMixinsinsrc/Neo.mjs, effectively copies methods from mixins to the target class's prototype. However, it does not automatically merge thestatic configproperties defined within mixins into thestatic configof the class that consumes them.This behavior means that default configuration values or new configurable properties introduced by a mixin are not automatically inherited by the consuming class. Developers are required to manually replicate or merge these configurations, which introduces boilerplate, increases the risk of errors, and diminishes the "plug-and-play" benefit of mixins for configuration.
Proposed Enhancement:
Modify the
applyMixinsfunction (or theNeo.setupClassprocess where mixins are applied) to intelligently merge thestatic configof each applied mixin into thestatic configof the target class. This merge should respect the inheritance hierarchy, allowing the consuming class's ownstatic configto override mixin configs, and later mixins to override earlier ones (or a defined merge strategy).Benefits: