Is there a way to refactor this code? #12460
Replies: 1 comment 1 reply
-
A bad repetition is better than a bad abstraction. Here your code has repetition but is easy to read and maintain, and that's what matters the most in any case (personal or professional project). I suppose you tried to abstract the logic from the effect and found that it was unpractical since param treatment isn't generic ( What I would do is isolate this file since Svelte5 now allows it, and let it live until its size actually becomes a problem (that would need quite some extra params). |
Beta Was this translation helpful? Give feedback.
-
I need all the below code to be able to persist in the URL (query string) some variables I'm using in a Svelte 5 / Svelte Kit project page.
I also need to assign URL query params to variables on page reload or page change.
As you can see the code is very repetitive and I think there must be a better way! (better = DRY and faster)
I created a small reproduction.
What do you think?
Beta Was this translation helpful? Give feedback.
All reactions