Replies: 2 comments
-
Thanks for opening up a suggestion. I think I understand where you come from. We have similar discussions from different angles, but it's a design decision. That said, apart from useSnapshot, proxy-compare and |
Beta Was this translation helpful? Give feedback.
-
Thanks for your response. I'm not opposed to figuring it out myself. I was just looking for a hint as to whether it was not possible or problematic. Based on your response, it seems that it's doable and worth exploration. Thank you. |
Beta Was this translation helpful? Give feedback.
-
Currently
set
traps are applied eagerly for all nested objects recursively. For performance reasons it would be better to apply them lazily after accessed withinuseSnapshot
.This would be similar to how
useSnapshot
lazily appliesget
traps recursively to nested objects.So the way to build this is to have
useSnapshot
apply bothget
andset
traps. And of course, theset
trap would only be applied the first time accessed. If another component usinguseSnapshot
already applied theset
trap for the same key, obviously it wouldn't apply it again.Has there been any research in this area or reasons why this is a bad idea?
Is there a possibility to miss a notification from set traps before they are lazily set?
This rewrite would allow for use of very large state objects without worry that performance will be taxed for storing lots of rarely touched domain models.
It seems proxy-compare would have to be more closely coupled to the code within valtio's vanilla.js file.
Beta Was this translation helpful? Give feedback.
All reactions