LearnNewsExamplesServices
Frontmatter
id7019
titleRefactor `defineComponent` and Enhance Config System Documentation
stateClosed
labels
enhancement
assigneestobiu
createdAtJul 11, 2025, 6:32 PM
updatedAtJul 11, 2025, 6:47 PM
githubUrlhttps://github.com/neomjs/neo/issues/7019
authortobiu
commentsCount1
parentIssue6992
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtJul 11, 2025, 6:47 PM

Refactor defineComponent and Enhance Config System Documentation

Closed v10.0.0-beta.6 enhancement
tobiu
tobiu commented on Jul 11, 2025, 6:32 PM

Summary

This work involved two main parts:

  1. Refactoring the defineComponent factory to use a more intuitive and accurate API.
  2. Significantly improving the JSDoc documentation for the core configuration system to make its powerful features more discoverable and understandable.

1. defineComponent Refactoring

The defineComponent function was updated to accept a config property in its specification object instead of the more generic static property.

Before:

defineComponent({
    static: {
        className: '...',
        text_: 'Hello'
    }
});

After:

defineComponent({
    config: { // More descriptive and accurate
        className: '...',
        text_: 'Hello'
    }
});

Reasoning

  • The key config directly maps to the static config property on the generated class, making the API more transparent and reducing the mental overhead for developers.
  • The term static was too generic, as its only purpose was to define configs.

2. Configuration System JSDoc Enhancements

Extensive improvements were made to the JSDocs in src/core/Base.mjs and src/Neo.mjs.

Key Improvements

  • core.Base.mjs (static config):

    • Clearly distinguished between reactive configs (e.g., name_) and non-reactive, prototype-based configs.
    • Explicitly documented all three optional lifecycle hooks for reactive configs: beforeGet<Name>(), beforeSet<Name>(), and afterSet<Name>(), including their parameters.
  • core.Base.mjs (applyOverwrites):

    • Added a detailed explanation of the Neo.overwrites mechanism.
    • Included a practical example demonstrating how to use overwrites to change a component's default values across an entire application, highlighting its power for reducing boilerplate code.
  • Neo.mjs (setupClass):

    • Expanded the documentation to describe its full role as the central orchestrator of class creation.
    • Explicitly mentioned that it calls applyOverwrites, connecting the global overwrite mechanism to the class setup lifecycle.

Outcome

The framework's API is now more intuitive, and the documentation for its sophisticated configuration system is significantly clearer and more comprehensive. This will lower the learning curve for new developers and serve as a better reference for experienced ones.

tobiu assigned to @tobiu on Jul 11, 2025, 6:32 PM
tobiu added the enhancement label on Jul 11, 2025, 6:32 PM
tobiu added parent issue #6992 on Jul 11, 2025, 6:32 PM
tobiu referenced in commit ef78b5f - "Refactor defineComponent and Enhance Config System Documentation #7019" on Jul 11, 2025, 6:34 PM
tobiu closed this issue on Jul 11, 2025, 6:34 PM
tobiu
tobiu Jul 11, 2025, 6:45 PM

let us enhance the setupClass() docs a bit more, to point out the gatekeeper role.

tobiu reopened this issue on Jul 11, 2025, 6:45 PM
tobiu referenced in commit 1f1d025 - "Enhance Config System Documentation #7019" on Jul 11, 2025, 6:45 PM
tobiu closed this issue on Jul 11, 2025, 6:47 PM