Replies: 1 comment
-
I think is generally a bad idea to have getters with side effects. Getters should be idempotent, and I wouldn't be surprised if the Svelte team is actually counting on idempotency in these in binding scenarios. My suggestion would be to avoid avoiding |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I’ve been exploring Svelte 5’s get/set pairs for state bindings and find them an amazing way to avoid $effect and untrack. They offer clear, event-driven logic and reduce boilerplate.
However, I noticed that getters can be called multiple times per update cycle, and at unpredictable times, which makes them problematic for side effects like data fetching or expensive computations. This unpredictability limits their use for those cases.
Here’s a minimal reproduction demonstrating this: link.
Has anyone found reliable patterns or best practices to handle such scenarios? Would love to hear community thoughts or possible improvements to the reactive model.
Beta Was this translation helpful? Give feedback.
All reactions