LearnNewsExamplesServices
Frontmatter
id7124
titleFeature Request: Refine StateProvider Change Notification Logic
stateClosed
labels
enhancement
assigneestobiu
createdAtJul 29, 2025, 4:15 PM
updatedAtJul 29, 2025, 4:17 PM
githubUrlhttps://github.com/neomjs/neo/issues/7124
authortobiu
commentsCount0
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtJul 29, 2025, 4:17 PM

Feature Request: Refine StateProvider Change Notification Logic

Closed v10.2.0 enhancement
tobiu
tobiu commented on Jul 29, 2025, 4:15 PM

Problem Description

In the Neo.state.Provider, the onDataPropertyChange() hook was being invoked even when a data property's value had not semantically changed. This led to unnecessary processing and potential feedback loops within applications using the state provider, particularly in scenarios involving two-way data binding and URL hash synchronization.

Solution Implemented

The #setConfigValue() method within src/state/Provider.mjs has been refined to conditionally call onDataPropertyChange().

  1. For existing data properties: The method now leverages the boolean return value of currentConfig.set(newValue). The Neo.core.Config.set() method, which internally uses Neo.isEqual(), accurately determines if a value has truly changed.
  2. For newly created data properties: onDataPropertyChange() is always triggered, as these represent a new addition to the state.

Rationale

This change ensures that onDataPropertyChange() is only executed when there is a genuine, semantic change in the data property's value. This aligns the StateProvider's behavior with the consistency model established by Neo.createConfig().set(), where the Config instance itself is responsible for determining if a value has changed.

The EffectManager.pause() mechanism already provides atomicity for reactive effects during bulk updates, meaning additional batching for onDataPropertyChange() calls is not required, as these notifications will not trigger effects until the EffectManager is resumed.

This refinement improves the efficiency and robustness of the StateProvider by preventing redundant change notifications and contributing to a more predictable state management system.

tobiu assigned to @tobiu on Jul 29, 2025, 4:15 PM
tobiu added the enhancement label on Jul 29, 2025, 4:15 PM
tobiu referenced in commit 8f9eec1 - "Feature Request: Refine StateProvider Change Notification Logic #7124" on Jul 29, 2025, 4:16 PM
tobiu closed this issue on Jul 29, 2025, 4:17 PM