Replies: 1 comment
-
Hi, where is it from the doc ? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
How does SWR guarantee causal consistency (if at all)? I see no mention of this in the docs.
e.g. from the docs:
The problem with this workflow is that anything else could cause a separate revalidation between step 2 and 3. That revalidation could finish before the POST does. This would clear the optimistic state, only to have it return again. Your optimistic changes would disappear before the final revalidation finishes, then reappear once it does. And that's assuming the last revalidation finishes last, which itself is not guaranteed. Otherwise your changes would simply disappear entirely until a future revalidation finally gets them.
I fail to see how SWR could possible know that I have a pending POST request and throw away validation responses which turned invalid during the course of being resolved. Since it doesn't even have knowledge of my POST request.
It would need to have an API like this to do that:
mutate({
key,
optimistic: synchronous transformer function,
request: async request function,
revalidate: true,
})
Am I missing something? Or is this just a design oversight?
Beta Was this translation helpful? Give feedback.
All reactions