Open VictorTaelin opened 8 years ago
There is a workaround, though, which is listing the dependencies with commas, like:
state(() => x(), y(), (x() ? 1 : y()))
But that is very demotivating, IMO. Maybe a explicit list of dependencies is the only way to do it.
Would it be possible to re-evaluate the dependencies each time the state is updated? I believe this is the approach Knockout.js takes for its computed observables.
Using default params you could write it as:
state((a = x(), b = y()) => a ? 1 : b)
Seems like I completely missed an obvious point. As commented by on Reddit,
The dependency detector will never realize the presence of
y()
since the branch isn't executed. I see no obvious way to fix this issue.