-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: Error
and Rollback
config keys => fns for handling error cases
#9
Comments
@MrNice Can you provide an example where these two options would be really useful? |
Totally. So, a user creates a new blog post and submits it through We care less about tags, so when the user then adds a tag to the existing blog post, we optimistically update the ui and give the tag a If the back end succeeds, we migrate the temp id to a real id in the tags state slice and in the blog's tags array. If it fails, I need to be able to allow the user to cancel the tag save attempt, which means either a retry, or a rollback. The rollback would unset the temp_id link in the blog tag array and remove the temp tag entity. An My goal is to allow redux-query to control the redux state transitions for mutations which succeed or fail, not just successful ones. At work I've been working on a Recap in case I drifted too much: |
@ryanashcraft I've been thinking about this and think it might be sensible to replace update w/ a small middleware pipeline because we're fundamentally dealing w/ http which has the application / protocol separated. Right now, update only takes body, and that can be implemented as a really simple one function middleware pipeline.But I could then implement error / rollback etc as a slightly different pipeline. |
@MrNice I don't understand the HTTP middleware pipeline proposal. I'm not sold on the utility of I do think there's something missing in the API to get error metadata. But I think this data should belong to the queries state, not entities state. If we do something like what I proposed here, would that take care of that use case? |
Implemented |
With redux query, if a user requests an entity which does not exist, how do I let them know?
My suggestion is to add two new functions alongside
update
andoptimisticUpdate
:error
to handle cases where no client state was optimistically updated, androllback
to handle undoing optimistic updates.Successful path where network and back end succeed:
Failure path where network or back end fails:
The text was updated successfully, but these errors were encountered: