rollbackOnError as function #2092
-
Hi 👋 I've noticed that 2 of the Use Case I thought maybe something like this const newData = createNewData(...);
mutate(key, updateFn(newData), {
revalidate: true,
populateCache: true,
optimisticData: newData,
rollbackOnError(error, currentData) {
if (error.name === "TimeOutError") {
return false;
}
return true;
},
}); I'm not sure such an implementation could work, please feel free to let me know or suggest alternatives. Maybe I'm going at it completely wrong. const newData = createNewData(...);
try {
const mutatedData = await mutate(key, data, {
populateCache: true,
optimisticData: newData,
rollbackOnError: false,
});
} catch (error) {
// Error might comme from unique constraint in database, unsufficient permissions, etc...
if (error.name !== "TimeoutError") {
mutate(key, newData, {
revalidate: false,
populateCache: true,
rollbackOnError: false,
});
}
} |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Thanks for sharing this idea, I create #2093 to track this feature request |
Beta Was this translation helpful? Give feedback.
Thanks for sharing this idea, I create #2093 to track this feature request