Re:Preact Signals
by fabiospampinato on Thursday September 08, 2022 @11:45AM
(#32767289)
The conditional check in the example code I provided is pretty much just the if/else that one writes, that's as closely located as you can possibly write it I guess. Like if some signals are read under a branch that's never taken they are just never read, that's it.
Also maybe there are good reasons for disliking it, but this seems harder to mess up, by default all dependencies are accounted for, automatically, that's not the case with dependencies arrays.
This is an anti-feature.
To elaborate, a “conditional dependency” is still a dependency as much as any regular dependency would be.
The only difference is that the conditional check is now taken outside the dependent code, (where the condition is both explicit and colocated with the dependent code) and put somewhere else, becoming less explicit and harder to find.