LearnNewsExamplesServices
Frontmatter
id7024
titleRefactor `Neo.core.Effect` to Use a Reactive `isRunning` State
stateClosed
labels
enhancement
assigneestobiu
createdAtJul 12, 2025, 4:48 PM
updatedAtJul 12, 2025, 5:32 PM
githubUrlhttps://github.com/neomjs/neo/issues/7024
authortobiu
commentsCount0
parentIssue6992
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtJul 12, 2025, 5:32 PM

Refactor Neo.core.Effect to Use a Reactive isRunning State

Closed v10.0.0-beta.6 enhancement
tobiu
tobiu commented on Jul 12, 2025, 4:48 PM

Summary: This ticket covers the refactoring of Neo.core.Effect to change its internal isRunning flag from a plain boolean to a reactive Neo.core.Config instance. This change was essential to break an infinite loop encountered in functional components, where an effect's execution was inadvertently creating a dependency on its own update cycle.

Rationale: Functional components use a central vdomEffect to re-render when state changes. The initial implementation caused an infinite loop because the effect's execution triggered an update process (updateVdom), which in turn read a reactive property (vnode) that was set at the end of the update. This created a feedback loop: effect -> update -> read vnode -> trigger effect.

To break this loop, the component needed to apply the VDOM update after the effect had finished running, outside of its tracking scope. Making Effect a full Observable was deemed too heavyweight. The most minimalistic and elegant solution was to make only the isRunning property observable.

Implementation Details:

  1. The isRunning property in Neo.core.Effect was changed from a boolean to an instance of Neo.core.Config, initialized with false.
  2. The run() method was updated to use isRunning.get() for checks and isRunning.set() to update the state.
  3. This allows consumer classes, such as Neo.functional.component.Base, to subscribe() to the isRunning config and safely trigger actions (like applying VDOM updates) when the state changes from true to false, effectively decoupling the action from the effect's dependency tracking.

Definition of Done:

  • Effect.isRunning is an instance of Neo.core.Config.
  • The run() method correctly uses get() and set() on isRunning.
  • The change successfully enables consumers to observe the effect's execution state, resolving the infinite loop problem in functional components.
tobiu assigned to @tobiu on Jul 12, 2025, 4:48 PM
tobiu added the enhancement label on Jul 12, 2025, 4:48 PM
tobiu referenced in commit 3090f97 - "Refactor Neo.core.Effect to Use a Reactive isRunning State #7024" on Jul 12, 2025, 4:49 PM
tobiu closed this issue on Jul 12, 2025, 5:32 PM
tobiu added parent issue #6992 on Jul 12, 2025, 8:28 PM