-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Runes: Determining what is reactive #9258
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Would be nice if the vscode extension could somehow help with this, similar to this effort: https://github.com/halfdanj/svelte-reactions |
An IDE extension would be nice (displaying all 'side-effects' of a variable on hover would be pure gold). It's possible, but quite heavy since the language server must parse the whole codebase. Other solutions that come to my mind:
|
IDE solutions are nice. Being able to accurately assess code while looking at a PR in GitHub is better. That requires a different language design than what is currently proposed. If the above example for Svelte 4, either I would know it was a store because of the $ prefix, |
Correct me if I get the runes wrong after playing with them a bit, but you can use runes only to define variables and at passing them wherever the reactivity gets lost. So However, if |
Technically it is |
That last point you considered is interesting. Because if its possible then no special syntax is needed, since everything is reactive. |
The example isn't reactive anyway, since |
Describe the problem
Consider the component
Is
cart
reactive? Does it update based on other things or is it grabbed one time? With Svelte 4, this is easy:getCart
either returned a store or it is not reactive.With Svelte 5, the only way to determine this is to open up the definition of
getCart
and see if$state
is used there. On any large project, the definition ofgetCart
probably will call shared helper/utility functions, so you'll have to check those too. Bonus points if it returned something created from inside ofnode_modules
.Describe the proposed solution
Explicit opt in to reactivitiy or a type used to denote the result of runes. I should understand how this file behaves by looking at just this one file, in isolation.
Alternatives considered
Importance
would make my life easier
The text was updated successfully, but these errors were encountered: