Skip to content

Why is watch is not selective? #640

Answered by dai-shi
stephenh asked this question in Q&A
Discussion options

You must be logged in to vote

I call what you call "selective", "usage tracking".

btw, get() returns a proxy object, not a snapshot object.

watch is simply wrapped around subscribe. So, it's by design.

The mental model is, all vanilla functions are simple ones without snapshot nor usage tracking. Usage tracking is only implemented in useSnapshot.

Now, implementing usage tracking in watch is a little complex, and usage comes with gotchas, and watch's implementation is actually already fairly complex.
Creating a new util extending subscribe with usage tracking is rather reasonable, but it might not be that intuitive, in terms of API surface.

Overall, while the question/suggestion is reasonable, it's by design, and I'm n…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by stephenh
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants