Son
Son8mo ago

Pending state for mutations and actions

is there some sort. a pending state i can access for mutations and actions As i live in Europe. updates are not instant. so being able to show the user a pending state would be awesome,
9 Replies
erquhart
erquhart8mo ago
If you run a mutation or action client side, it returns a promise. As long as the promise is unresolved, you can consider it to be loading. For the gap between mutation complete and query update, I'd recommend using optimistic updates for places in your app where you need a fast response.
Son
SonOP8mo ago
Thanks for the explanation id probably run it through react query, so i don't have to manually create the same boiler plate for each mutation/action. ill just pass the promise to react query and let it handle it automatically. is that a valid option in your opinion?
Michal Srb
Michal Srb8mo ago
Have you checked out https://docs.convex.dev/client/react/optimistic-updates ? If you want a simple "inProgress" you can use React setState, it's pretty minimal. If you do end up using react query with Convex let us know how it went.
Optimistic Updates | Convex Developer Hub
Even though Convex queries are completely reactive, sometimes you'll want to
erquhart
erquhart8mo ago
I know folks are using React Query with Convex, and I assume it's working fine as I haven't heard otherwise. But I've used (and very much enjoyed!) react query and similar libraries in the past, and I suspect they'll add more complexity than they remove. Especially because these libraries are built to server as client stores, which Convex's React library already does really well. Feels heavy for what really just comes down to ergonomics. Would be cool if someone came up with a thin wrapper for Convex React lib that just provides the beloved { data, loading, error } style response objects without the boilerplate folks are trying to avoid.
Son
SonOP8mo ago
your right its about ergonomics, and developers are lazy
erquhart
erquhart8mo ago
hahaha yes we are
Son
SonOP8mo ago
this would be KING!
erquhart
erquhart8mo ago
@Son check it out: https://discord.com/channels/1019350475847499849/1227707978824552449/1243119101589585920 Note that it's very new and not yet tested, feel free to give it a try and provide any feedback you have in that thread I linked
Son
SonOP8mo ago
Thanks!

Did you find this page helpful?