Skip to content
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

Optimistic query #423

Open
klis87 opened this issue Dec 30, 2020 · 4 comments
Open

Optimistic query #423

klis87 opened this issue Dec 30, 2020 · 4 comments

Comments

@klis87
Copy link
Owner

klis87 commented Dec 30, 2020

It could be beneficial to add something like optimistic query. It would allow to update data before query response, which could be known in advance.

Use case? For example server side pagination, imagine you have currentPage in data, if you pass it to a pagination component, then it would work, but paginator would be updated only on query response. People would expect current page to be updated at once, not after data for the new page arrives. Right now it is achievable by introducing an extra local state to store current page, I think optimistic query would be more elegant.

@iwan-uschka
Copy link

In case anyone is not convinced by reading your example, I have one that at least convinced me (taken from https://levelup.gitconnected.com/optimistic-updates-in-react-803003844cb0):

For example, if you are building a Kanban board tool where your users can drag cards back and forth between columns waiting for the response from the server destroys the experience. Each time the user drags a card it’s going to jump back to its previous column until the server responds (which can take many seconds on a slow connection). You might think that this is only an issue with slow connections. But, if you try to implement something like a Kanban board this way, you will quickly realize, even if you’re on a really solid internet connection, that the card will quickly jump back to its previous position before taking its new one. Even if it’s just for a split second this can cause a user to have a pretty bad experience.

@klis87
Copy link
Owner Author

klis87 commented Jan 17, 2021

@iwan-uschka hmm, but this example isn't about optimistic updates already implemented in this lib? Dragging card is probably a mutation, which already has optimistic support. You can even see this in action in the readme - showcase example, where you do dnd with react beautiful dnd, with optimistic update it looks cool, but without it, you have this weird effect after releasing the button, for example if you have order 1 2 3, you drag as 2 3 1, then without optimistic update it will go back to 1 2 3 on release, just to go back to 2 3 1 on response.

@iwan-uschka
Copy link

Sorry!! Like i mentioned in #432 (comment) i just discovered some features in this lib. I'll stop posting until i fully reread the docs (which i haven't done for quite a while, it seems).

@klis87
Copy link
Owner Author

klis87 commented Jan 17, 2021

@iwan-uschka no worries, perhaps it would be easier for you to analyze https://github.com/klis87/redux-requests/releases , then you will quickly see what's new :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants