LearnNewsExamplesServices
Frontmatter
id7100
titleRefactor: Move State Provider logic to component.Abstract
stateClosed
labels
enhancement
assigneestobiu
createdAtJul 23, 2025, 2:05 PM
updatedAtOct 23, 2025, 12:54 AM
githubUrlhttps://github.com/neomjs/neo/issues/7100
authortobiu
commentsCount0
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtJul 23, 2025, 2:06 PM

Refactor: Move State Provider logic to component.Abstract

Closed v10.0.0 enhancement
tobiu
tobiu commented on Jul 23, 2025, 2:05 PM

Description

Currently, all logic related to state.Provider (the bind and stateProvider_ configs, the getStateProvider() method, etc.) resides entirely within src/component/Base.mjs.

The base class for functional components, Neo.functional.component.Base, extends Neo.component.Abstract but does not extend Neo.component.Base. This architectural separation prevents functional components from accessing and using state providers, which is a key feature for v10.

The createVdom method signature in functional.component.Base was already updated to anticipate access to provider data via config.data, making it clear that this functionality is intended.

Task

To solve this, we need to refactor the state provider logic out of component.Base and move it up the inheritance chain into component.Abstract. This will make the state provider system available to both classic class-based components and modern functional components.

Key Logic to Move

The following configs, methods, and lifecycle logic must be moved from src/component/Base.mjs to src/component/Abstract.mjs:

  • Configs:
    • bind
    • modelData
    • stateProvider_
    • data_ (the convenience getter)
    • parentComponent_ (dependency for getConfigInstanceByNtype)
  • Methods:
    • beforeSetStateProvider()
    • afterSetStateProvider()
    • getStateProvider()
    • getState()
    • setState()
    • beforeGetData()
    • getConfigInstanceByNtype() (dependency for getStateProvider)
  • Lifecycle Logic:
    • The stateProvider related calls inside destroy(), initConfig(), and onConstructed() need to be moved.
  • Two-Way Binding Logic:
    • The logic inside afterSetConfig() that handles two-way data binding needs to be moved.

Affected Files

  • src/component/Abstract.mjs (target for new logic)
  • src/component/Base.mjs (source of logic to be moved)
  • src/functional/component/Base.mjs to not pass data to createVdom() => performance => access via config.data
tobiu assigned to @tobiu on Jul 23, 2025, 2:05 PM
tobiu added the enhancement label on Jul 23, 2025, 2:05 PM
tobiu referenced in commit aad159e - "Refactor: Move State Provider logic to component.Abstract #7100" on Jul 23, 2025, 2:05 PM
tobiu closed this issue on Jul 23, 2025, 2:06 PM