Replies: 6 comments 5 replies
-
If we do this, I would move the current implementation to a third-party package: https://www.npmjs.com/package/derive-valtio |
Beta Was this translation helpful? Give feedback.
-
Am I misunderstanding the proposed alternative, or will object getters get executed every single time they are accessed? My understanding was that the point of computed state was that it updates and gets computed when its dependencies change, because otherwise you could just use any old helper function in your render logic to work with your store. |
Beta Was this translation helpful? Give feedback.
-
If we were to keep |
Beta Was this translation helpful? Give feedback.
-
Hi someone, I really need to understand some use cases that only work with derive. Can anybody share ideas that seem difficult with object getters? From the library maintenance perspective, the major version up is the only way to drop a feature. |
Beta Was this translation helpful? Give feedback.
-
After merging #798, I will move the derive util to another repo, and make it a dependency. |
Beta Was this translation helpful? Give feedback.
-
This is a huge idea, because I have been preferring and recommending
derive
for computed properties for most cases.Recently, we updated docs with #647 by @stephenh and #732 by @alexander-entin.
It turns out that object getters work pretty well if we use it carefully.
We have some open issues with
derive
#685 and #687 and I'm currently not very confident with its implementation. We could try fixing it or even re-implementing it.On the other hand, having two ways for computed properties is confusing and worse in DX.
So, I would like to recommend using object getters instead of
derive
.The
derive
util will be maintained in a separate package, and will be removed from Valtio v2 #703.There are a few issues:
subscribe
orwatch
for workaroundsWhat we need to do is to collect
derive
usage and see if it's possible to migrate to object getters.Beta Was this translation helpful? Give feedback.
All reactions