Description
This feature refactors Neo.state.Provider to fully integrate the new Neo.core.Effect system and Neo.state.HierarchicalDataProxy. This replaces the previous custom, ad-hoc reactivity mechanism within state.Provider, leading to a more consistent, efficient, and maintainable data binding system.
Motivation
The existing state.Provider used a custom implementation for managing reactive data properties and their bindings to components. This approach had several drawbacks:
- Inconsistency: It diverged from the
Neo.core.Config reactivity model, creating two separate ways to handle reactive data within the framework.
- Complexity: The manual dependency tracking and update propagation within
state.Provider were complex and prone to subtle bugs, especially with nested and hierarchical data.
- Maintainability: The custom reactivity logic made
state.Provider harder to understand, debug, and extend.
This refactoring addresses these issues by leveraging the newly introduced Effect system and HierarchicalDataProxy.
Implementation Details
- Internal Data Storage:
state.Provider now stores its data properties internally as Neo.core.Config instances, unifying its reactivity with the core framework. The afterSetData method has been updated to manage these Config instances.
- Simplified Bindings: The
createBinding() method has been completely refactored. It now creates a Neo.core.Effect instance that wraps the component's binding formatter. This Effect automatically tracks dependencies via the HierarchicalDataProxy and updates the component's config when any of those dependencies change.
- Hierarchical Data Access:
getHierarchyData() now returns the HierarchicalDataProxy, enabling seamless and reactive access to data across the provider hierarchy.
- New Helper Methods:
getDataConfig(), getOwnerOfDataProperty(), and hasNestedDataStartingWith() have been added to state.Provider to support the HierarchicalDataProxy's operation.
- Cleanup: Obsolete methods and manual binding management logic have been removed, including
createDataProperty(), onDataPropertyChange(), getFormatterVariables(), and the old manual bindings map. This significantly reduces the complexity and size of state.Provider.
setData() Refactored: The setData() and internalSetData() methods have been updated to interact directly with the Neo.core.Config instances.
Benefits
- Unified Reactivity: Aligns
state.Provider's data binding with the core Neo.core.Config reactivity model, improving consistency across the framework.
- Increased Robustness: The
Effect system provides a more reliable and less error-prone mechanism for dependency tracking and change propagation.
- Improved Maintainability: Simplifies
state.Provider's codebase, making it easier to understand, debug, and extend.
- Enhanced Performance: The lightweight
Effect class and optimized dependency tracking contribute to better overall performance.
Future Considerations
- Two-Way Binding: The two-way binding mechanism needs to be re-evaluated and adapted to the new
Effect system.
- Formulas: The
formulas config in state.Provider will need to be updated to leverage the new Effect system for its reactive computations.
Description
This feature refactors
Neo.state.Providerto fully integrate the newNeo.core.Effectsystem andNeo.state.HierarchicalDataProxy. This replaces the previous custom, ad-hoc reactivity mechanism withinstate.Provider, leading to a more consistent, efficient, and maintainable data binding system.Motivation
The existing
state.Providerused a custom implementation for managing reactive data properties and their bindings to components. This approach had several drawbacks:Neo.core.Configreactivity model, creating two separate ways to handle reactive data within the framework.state.Providerwere complex and prone to subtle bugs, especially with nested and hierarchical data.state.Providerharder to understand, debug, and extend.This refactoring addresses these issues by leveraging the newly introduced
Effectsystem andHierarchicalDataProxy.Implementation Details
state.Providernow stores its data properties internally asNeo.core.Configinstances, unifying its reactivity with the core framework. TheafterSetDatamethod has been updated to manage theseConfiginstances.createBinding()method has been completely refactored. It now creates aNeo.core.Effectinstance that wraps the component's binding formatter. ThisEffectautomatically tracks dependencies via theHierarchicalDataProxyand updates the component's config when any of those dependencies change.getHierarchyData()now returns theHierarchicalDataProxy, enabling seamless and reactive access to data across the provider hierarchy.getDataConfig(),getOwnerOfDataProperty(), andhasNestedDataStartingWith()have been added tostate.Providerto support theHierarchicalDataProxy's operation.createDataProperty(),onDataPropertyChange(),getFormatterVariables(), and the old manualbindingsmap. This significantly reduces the complexity and size ofstate.Provider.setData()Refactored: ThesetData()andinternalSetData()methods have been updated to interact directly with theNeo.core.Configinstances.Benefits
state.Provider's data binding with the coreNeo.core.Configreactivity model, improving consistency across the framework.Effectsystem provides a more reliable and less error-prone mechanism for dependency tracking and change propagation.state.Provider's codebase, making it easier to understand, debug, and extend.Effectclass and optimized dependency tracking contribute to better overall performance.Future Considerations
Effectsystem.formulasconfig instate.Providerwill need to be updated to leverage the newEffectsystem for its reactive computations.