Why doesn't Valtio automatically track dependencies? #950
Closed
transitive-bullshit
started this conversation in
General
Replies: 1 comment 3 replies
-
Because it's not the goal nor the scope. fyi, the goal of valtio is to create immutable snapshots. const p = proxy({ count: 1 });
const s1 = snapshot(p);
p.count = 2;
const s2 = snapshot(p);
// s1 should be { count: 1 } and s2 should be { count: 2 } |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
During my deep-dive comparison of reactive TS frameworks, I was surprised to see that Valtio doesn't automatically track dependency reads in its computed properties or
subscribe
(which seems like the closest analog Valtio has to aneffect
).#149 seems to have settled on a compromise by adding an optional
watch
tovaltio/utils
which at least makes dependency tracking possible, albeit with a somewhat awkward manual DX compared to other similar reactive libs (example which I may or may not have butchered 😂 ).I know the authors of this project likely have a very good reason for this design decision, but I wasn't able to understand it by searching through the repo and old issues.
Related: #149 and potentially #82
I'd love to update my comparison with an explanation of how you guys think about automatic dependency tracking versus the more explicit approach taken by libs like Valtio and Jotai.
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions