Comments (3)
Upon a little more digging, the core query
object in react-query
~ seems ~ to return the same promise. Specifically, in query.fetch
source:
fetch(
options?: QueryOptions<TQueryFnData, TError, TData>,
fetchOptions?: FetchOptions
): Promise<TData> {
if (this.state.isFetching)
if (this.state.dataUpdatedAt && fetchOptions?.cancelRefetch) {
// Silently cancel current fetch if the user wants to cancel refetches
this.cancel({ silent: true })
} else if (this.promise) {
// Return current promise if we are already fetching
return this.promise
}
...
And query
objects are cached in a queryMap
that's used by each queryClient
.
The big caveat is that I've researched this all of 5 mins, while you obviously know a lot more about this whole thing (to the point where you created a package specifically to solve this problem), so I apologize beforehand for the great likelihood that I'm misunderstanding the whole thing.
from memoized-node-fetch.
Hello @fivecar! Thanks for the interest and the nice words!
When I created this package, react-query was somewhere around version 2.19.0. Back then, after some people asked me, I checked if react-query does promise caching, and as far as I digged into it, I didn't find any evidence of promise caching.
It seems like this feature was added with v3 around 10 months ago.
Some more facts:
- When I created this package, I mostly intended to use it in nodejs, and not in the browser, so I didn't even consider checking any existing packages for the browser.
- Well, react-query does 100,000 more things (which is generally good) but some times you don't need all of those, so if that's the case, I would choose my package.
from memoized-node-fetch.
Awesome - super-helpful, @chrispanag ! I've created #8 as a result of your thorough explanation, which I really appreciate!
Thanks again for all the time and effort you put into this. Love it!
from memoized-node-fetch.
Related Issues (1)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from memoized-node-fetch.