Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Now I’m using svelte-query but I’m not happy with it: it has not-so-convenient APIs (@benbender is working on it, but the maintainer is not so active, so I doubt it will change in a short time).

After the “fix” for Svelte Kit I’m trying sswr.

The first “issue” is about the query keys. Svelte-Query also allows you to use an array of keys for use cases such as pagination or filtering, you know…

What do you think about?

Is it so hard to add?

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:28 (28 by maintainers)

github_iconTop GitHub Comments

benbendercommented, Aug 12, 2021

afaik your swr wont run again in react if some fetcher dependency changes. Only if you specify it on the key array and using the value provided in the fetcher function’s param will re-trying that update.

Yes and no 😃 swr runs again, but it doesn’t fetch again because the logic is wrapped in useCallback().

Thing is that all those “hooks” like useEffect(), useState(), useCallback() etc in React are basically methods to rip bits and pieces of code/state out of the normal react-rerender-flow to make them stateful. It’s, more or less, a band-aid to have statefulness in functional components in react. Thats exactly what’s happening here.

The beauty of svelte is that it gets rid of all those band-aid-concepts react introduced - and we are used to - for the past several years 😃

About array-keys: they aren’t only used for dependency-tracking but also to differentiate different results of requests and group requests with context. So there would be a benefit having something like that…

benbendercommented, Aug 10, 2021

quick note on my efforts regarding react-query: I’m thinking about abandoning my efforts as I start to realize that its not a great fit into the sveltekit-ecosystem in the first place. It replicates state-handling and reactivity where it isn’t needed in svelte(kit) because both are built-in. And react-query is therefor quite heavy in relation to sveltekit itself… Most use-cases of react-query should be achiveable with much less code.

I’m also generally start to questioning the whole idea of explicit caches for queries/mutations on an app-level, as it is basically a duplication of the builtin http-caching in browsers (at least for everything http-related). F.e. preloading is a breeze with sveltekits routing and even could be supported by the built-in support for service-workers. So there is basically only a small margin of cases where a solution on the app-level seems to be worth the effort anyways (given that the api, you are trying to reach, does http-caching right).

Oh, and I would love to see solutions for svelte which embraces the approach of sveltekits sample-todo-app, which leverages basic http to handle forms with progressive enhancement and are even working without js at all…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Array.prototype.keys() - JavaScript - MDN Web Docs
The keys() method returns a new Array Iterator object that contains the keys for each index in the array. Try it.
Read more >
JavaScript Array keys() Method - W3Schools
The keys() method returns an Array Iterator object with the keys of an array. The keys() method does not change the original array....
Read more >
array_keys - Manual - PHP
array_keys() returns the keys, numeric and string, from the array . If a filter_value is specified, then only the keys for that value...
Read more >
JavaScript Array keys() Method - GeeksforGeeks
The Javascript array.keys() method is used to return a new array iterator which contains the keys for each index in the given input...
Read more >
JavaScript Array keys() (With Examples) - Programiz
In this tutorial, you will learn about the JavaScript Array keys() method with the help of examples. The keys() method returns a new...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found