Describe the bug
The Neo.core.Effect.run() method was executing an additional, unintended time, leading to incorrect behavior in reactive bindings. This was observed in tests where effects were expected to run only once initially, but were running twice.
To Reproduce
Steps to reproduce the behavior:
- Run the test suite
tests/state/Provider.mjs.
- Observe failed assertions related to
effectRunCount, such as:
Binding effect should run once initially (Expected: 1, Got: 2)
Binding effect should re-run after setData (Expected: 2, Got: 4)
- Similar failures in hierarchical data access tests.
Expected behavior
The Neo.core.Effect.run() method should execute only once per intended trigger. The effectRunCount in the tests/state/Provider.mjs should match the expected values (e.g., 1 for initial run, 2 after first setData, etc.).
Additional context
This regression was introduced when the isRunning property of Neo.core.Effect was changed to a Neo.core.Config instance. The Effect was inadvertently subscribing to its own isRunning changes during its execution, creating a circular dependency that caused run() to be invoked recursively.
The fix involved strategically pausing and resuming EffectManager's dependency tracking within the Effect.run() method to prevent the Effect from registering itself as a dependency of its own isRunning config during its execution, and to prevent recursive calls when isRunning was set.
Describe the bug The
Neo.core.Effect.run()method was executing an additional, unintended time, leading to incorrect behavior in reactive bindings. This was observed in tests where effects were expected to run only once initially, but were running twice.To Reproduce Steps to reproduce the behavior:
tests/state/Provider.mjs.effectRunCount, such as:Binding effect should run once initially(Expected: 1, Got: 2)Binding effect should re-run after setData(Expected: 2, Got: 4)Expected behavior The
Neo.core.Effect.run()method should execute only once per intended trigger. TheeffectRunCountin thetests/state/Provider.mjsshould match the expected values (e.g., 1 for initial run, 2 after firstsetData, etc.).Additional context This regression was introduced when the
isRunningproperty ofNeo.core.Effectwas changed to aNeo.core.Configinstance. TheEffectwas inadvertently subscribing to its ownisRunningchanges during its execution, creating a circular dependency that causedrun()to be invoked recursively.The fix involved strategically pausing and resuming
EffectManager's dependency tracking within theEffect.run()method to prevent theEffectfrom registering itself as a dependency of its ownisRunningconfig during its execution, and to prevent recursive calls whenisRunningwas set.