LearnNewsExamplesServices
Frontmatter
id6965
titleFeature: Implement Neo.state.createHierarchicalDataProxy for reactive state provider data access
stateClosed
labels
enhancement
assigneestobiu
createdAtJul 6, 2025, 8:41 PM
updatedAtOct 23, 2025, 12:56 AM
githubUrlhttps://github.com/neomjs/neo/issues/6965
authortobiu
commentsCount0
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtJul 6, 2025, 9:11 PM

Feature: Implement Neo.state.createHierarchicalDataProxy for reactive state provider data access

Closed v10.0.0-beta.5 enhancement
tobiu
tobiu commented on Jul 6, 2025, 8:41 PM

Exploration quest inside the effect-based-state-provider feature branch

Description

This feature introduces Neo.state.HierarchicalDataProxy, a new Proxy class designed to provide reactive and hierarchical access to data managed by Neo.state.Provider instances. It acts as a crucial bridge, enabling the new Neo.core.Effect system to automatically track dependencies within the state provider's data hierarchy.

Motivation

The Neo.state.Provider system allows for nested and hierarchical data structures, where components can bind to data properties that might reside in their own provider or any parent provider. To integrate this complex data model with the new Neo.core.Effect system, a specialized mechanism is required that can:

  • Transparently resolve data properties across the provider hierarchy.
  • Intercept property access to dynamically register dependencies with the currently running Effect.
  • Maintain the performance and reactivity expected from the framework.

Implementation Details

  1. Neo.state.HierarchicalDataProxy (New Class: src/state/HierarchicalDataProxy.mjs):
    • A Proxy that wraps the conceptual merged data of a state.Provider and its ancestors.
    • Its get trap is the core of its functionality:
      • When a property is accessed (e.g., data.user.firstname), it dynamically searches up the state.Provider hierarchy to find the state.Provider instance that "owns" that specific data property.
      • It then retrieves the corresponding Neo.core.Config instance for that data property from the owning provider.
      • Crucially, if an Neo.core.Effect is currently running (as determined by Neo.core.EffectManager), the HierarchicalDataProxy registers this Neo.core.Config instance as a dependency for that Effect.
      • It returns the value from the Neo.core.Config instance.
    • Supports nested property access by returning new HierarchicalDataProxy instances for intermediate paths (e.g., accessing data.user returns a proxy for the user object, which then allows access to data.user.firstname).

Benefits

  • Seamless Integration: Provides a transparent way to access hierarchical state provider data within reactive computations.
  • Automatic Dependency Tracking: Eliminates the need for manual dependency declaration, simplifying binding logic and reducing potential errors.
  • Performance: Optimized to efficiently traverse the provider hierarchy and interact with Neo.core.Config instances.
  • Foundation for Refactoring: Lays the essential groundwork for refactoring Neo.state.Provider to fully utilize the new Effect system.
tobiu assigned to @tobiu on Jul 6, 2025, 8:41 PM
tobiu added the enhancement label on Jul 6, 2025, 8:41 PM
tobiu changed title from Feature: Implement Neo.state.HierarchicalDataProxy for reactive state provider data access to Feature: Implement Neo.state.createHierarchicalDataProxy for reactive state provider data access on Jul 6, 2025, 9:09 PM
tobiu referenced in commit 96a0173 - "Feature: Implement Neo.state.createHierarchicalDataProxy for reactive state provider data access #6965" on Jul 6, 2025, 9:10 PM
tobiu closed this issue on Jul 6, 2025, 9:11 PM
tobiu referenced in commit ac4810a - "Feature: Implement Neo.state.createHierarchicalDataProxy for reactive state provider data access #6965" on Jul 6, 2025, 9:48 PM
tobiu cross-referenced by #6966 on Jul 6, 2025, 9:49 PM
tobiu referenced in commit 4720f89 - "Feature: Implement Neo.state.createHierarchicalDataProxy for reactive state provider data access #6965" on Jul 9, 2025, 2:10 AM
tobiu referenced in commit eff9df6 - "Feature: Implement Neo.state.createHierarchicalDataProxy for reactive state provider data access #6965" on Jul 9, 2025, 2:10 AM