Closed airhorns closed 2 years ago
Wow, nice to see having comments on this repo. Happy to discuss.
Does the swr strategy in urql
and apollo
work in render-as-you-fetch?
AFAIU, in render-as-you-fetch, we get stale state with useTransition
.
For refetch, I was probably expecting to use a new param (new object, or new id). Not sure if it's easy to understand and accomplish things DX-wise.
@airhorns The getResult
throws a promise, which is caught by Suspense, so if you're using Suspense, that would automatically show the fallback view. I think what would be cool is to have another getResult
that doesn't throw the promise, which could be used in a refetch
method.
Yeah, it should make more sense if refetch
doesn't thorw a promise.
For now we encourage using useTransition
to keep previous state.
Hey there -- thanks for this awesome example of a render-as-you-fetch library! I understand that it's experimental and new, but, it'd be really awesome to get support for refetching in the background while rendering with the latest fetched version that's available on the client.
urql
andapollo
call this the stale-while-revalidate cache strategy: serve stale data to the react app while revalidating that it is fresh from the server.I think the current API makes that kind of hard to implement in userland because a fetch is only triggered after an eviction, so you'd have to evict the current data to trigger a refetch, leaving you no data in the meantime to render with.