Skip to content
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

Linking $effect to the older subscribe() function in the documentation. #15131

Open
peterhoward42 opened this issue Jan 28, 2025 · 1 comment

Comments

@peterhoward42
Copy link

Describe the problem

I did not realise that $effect can be used as a drop-in replacement where Svelte4 code that uses subscribe() to a store value - despite reading and revisiting the documentation several times.

This despite being now quite comfortable with $state runes and replacing most of my stores with them.

I suspect that many Svelte4 developers will be accustomed and comfortable with the idea and the terminology of "subscribe".

And is not $effect effectively an implicit subscriber? I have now found switching my subscribers to $effects is painless and produces clearer code.

Describe the proposed solution

I think that explaining in the documentation that $effect can be viewed as an implicit subscriber, and as being a good replacement for the older subscribe function will greatly speed up and ease people "getting" it.

I've made a similar suggestion suggesting the same pattern in this issue #14975

The pattern I'm advocating in both issues is to get people on the "right page" conceptually by leading the narrative with the problems that a feature solves, or example use cases, and only then explaining how the feature is a solution.

Importance

nice to have

@rChaoz
Copy link
Contributor

rChaoz commented Jan 29, 2025

And issue is that only works inside .svelte files - REPL, while .subscribe() can by used anywhere, and $effect() can be used in any .svelte.js file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants