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
First my question is if the chain of mutates is correct like this, especially in the error case.
Then I generate a new Error object with a retry function that can be used by the UI code to show a toast to retry the operation at later time (upon user interaction).
I wonder if the dependencies to setFavourite are still valid at the time retry() would be called. I guess not, as they depend on data and if this changes, then the setFavourite is also regenerated.
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
-
I'd like to make my swr state mutations resilient against network errors and support some kind of retry functionality.
Basically what I do is inside my useSWR powered hook:
First my question is if the chain of mutates is correct like this, especially in the error case.
Then I generate a new Error object with a
retry
function that can be used by the UI code to show a toast to retry the operation at later time (upon user interaction).I wonder if the dependencies to setFavourite are still valid at the time
retry()
would be called. I guess not, as they depend ondata
and if this changes, then thesetFavourite
is also regenerated.Anybody implemented such kind of retry before?
Beta Was this translation helpful? Give feedback.
All reactions