T
TanStack2w ago
exotic-emerald

Idea: add pendingMs / minPendingMs for mutation isPending

Hello! I was wondering if it could make sense to add pendingMs and minPendingMs (similar to what exists in TanStack Router) for the isPending state (or more likely a derived state, I don't know) in TanStack Query. For context, I generally avoid optimistic updates (complexity and other reasons lol), so I use the onSuccess callback of mutations to update the data. While a mutation is in progress, I disable parts of my UI (like reduce opacityor show a loading state) so the user knows something is happening. But the problem is when a request is very quick (like < 100ms), the loading UI flash, which isn't great. With something like pendingMs and minPendingMs: - If the request end before pendingMs --> no loading state shown - If it lasts slightly longer (like 105ms), --> loading state would still be up for at least minPendingMs (like 150–200ms) This makes fast requests feels like optimistic updates while still giving nice feedback for slow connections. Since TanStack Router uses this, I was curious whether something similar would make sense in TanStack Query or not... ? Thanks for any insight! PS: maybe I thinking this wrong, and you have better ideas to solve this "problem", do not hesitate :D.
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?