You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi all, I have such a use case - list of records is rendered, then several of records may be updated multiply times during short period.
Imagine user drags and drops group of objects several times.
So each record has x, y coordinates fields.
What I am doing currently - I update data using my api and post requests and then mutate swr cache with revalidate false. Only when user deselects this group of objects I am invalidating swr cache, so only one real fetch happens at the end.
It's good for performance but for some reasons out of scope of this discussion I want to not wait for deselection to trigger swr cache revalidation, but to have some debounced revalidation call after each drop.
So if user constantly dragging and dropping blocks no fetching will happen until user will calm down and wait at least for two secs.
I see by default swr has an option for deduplication 2secs, does it mean swr already will behave as I need?
Main questions are:
if i mutate cache without revalidation - will it be a reason for swr to ignore deduplication option or not?
how exactly deduplication works? If we compare it with lodash debounce - does it make only first fetch in sequence of rapid requests, only last one, or both, or maybe it makes some additional fetching in the middle?
If i do 10 revalidate calls each 1 second - what exactly will happen?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi all, I have such a use case - list of records is rendered, then several of records may be updated multiply times during short period.
Imagine user drags and drops group of objects several times.
So each record has x, y coordinates fields.
What I am doing currently - I update data using my api and post requests and then mutate swr cache with revalidate false. Only when user deselects this group of objects I am invalidating swr cache, so only one real fetch happens at the end.
It's good for performance but for some reasons out of scope of this discussion I want to not wait for deselection to trigger swr cache revalidation, but to have some debounced revalidation call after each drop.
So if user constantly dragging and dropping blocks no fetching will happen until user will calm down and wait at least for two secs.
I see by default swr has an option for deduplication 2secs, does it mean swr already will behave as I need?
Main questions are:
if i mutate cache without revalidation - will it be a reason for swr to ignore deduplication option or not?
how exactly deduplication works? If we compare it with lodash debounce - does it make only first fetch in sequence of rapid requests, only last one, or both, or maybe it makes some additional fetching in the middle?
If i do 10 revalidate calls each 1 second - what exactly will happen?
Beta Was this translation helpful? Give feedback.
All reactions