Undoable Mutations
mutate() runs. Here's a summary of what I want to happen after running mutate():1. Do an Optimistic Update.
2. Run
onSuccess and onSettled callbacks.3. Show a notification with an undo button for 3 seconds. If the undo button is clicked, reverse the Optimistic Update and cancel the mutation.
4. After 3 seconds, if the undo button wasn't clicked, run the
mutationFn.I've tried a few approaches, but it always feels hacky.
How would you implement such a feature? Is there any example that can inspire me?