Closed kentcdodds closed 1 year ago
Hi Kent 👋 Sounds useful to me 👍
To be clear: When you say "In the background", you mean a case where the cachified
call returned a stale cache value and getFreshValue
is called in the background to eventually provide a fresh value for the next call right?
Exactly 👍
Could you give cachified@3.1.0-context-info.1
a try?
The info is passed on the new GetFreshValueConext
cachified({
/* ... */
ttl: 5,
staleWhileRevalidate: 20,
getFreshValue({ background }) {
console.log(background);
return 'value'
}
});
Sweet! I'll give this a try soon and report back. Thanks!
Works great 👍 Thank you.
Glad to hear that! It's released under v3.1.0
Super, thanks a lot :)
Here's what I've got:
I have the
abortTimeoutSignal
thing in place so gravatar won't cause me issues if my page is waiting on it. I think if my page is waiting on it I'd prefer that the timeout time be more like 500ms, but if the update is happening in the background (SWR) then I'm fine with it taking even 10 seconds. Thoughts? Maybe an argument passed togetFreshValue
?