query debounce

Hey there ! I wonder if anyone could point me to a standard recipe to achieve query debouncing and caching using trpc and useQuery in react. I'm basically firing an api call everytime the user change his input which start to be quite a lot when he keep the "delete" key pressed on the keyboard.
N
Nick379d ago
You can debounce the parameters which drive useQuery instead There are several useDebounce hooks out there 🙂
A
avallete379d ago
Hey ! Thank's for the answer. Yes indeed there is several options out there. That's why I wondered if there were a "recommended" one. What I can think of when I think of debounce is 2 things: 1. Not calling the endpoint at all with as you mentioned parameters debouncing 2. Cancelling actives queries on a defined endpoint to only get result "for the last one" (especially efficient if the query response time is long but params debounce time is short). 3. A combination of the two ?
N
Nick379d ago
Ideally both! Ultimately do what solves your problems and no more, though
More Posts
Type of createServerSideHelpers?I'm currently trying to implement a helper for `getServerSideProps` to reduce duplication. It's stilhow to set request timeout in clientcreateProxyClient has no option about timeout like axios does. Just in one router request (query or trpc rate limitinghi I am currently having some problems with a race condition in my TRPC nextJS api. Essentially whtrpc pipe middlewareHey all. I'm currently trying to create a middle ware on endpoints using the new `pipe` API. This Has anyone ever used tRPC (with SSR) and i18n?No matter the lib (next-intl, next-i18n, next-translate), I simply stumble from one problem to anothNew to tRPC and Need Help with BasicsI made a new T3 app, but I don't quite understand how tRPC works, and I would love to get some help web socket keeps on disconnecting and connectingHi! Its my first time using web sockets. The first code snippet is my socket code. The second code sPagination QueryHi, I'm new for web dev and I'm moved to tRPC not so long I'm looking for example of pagination quEnrich the response object for TRPC endpointCurrently when I hit a trpc endpoint I get something like: ```typescript { result: { data:Can i fetch tRPC in different project@coco- : I Make a tRPC in my project. Can I use the enpoint api in different project ?Importing AppRouter types from an external repoI've got a production T3 app already in production. I've created a fresh expo app to start building TypeScript type for request object for route handlersSo far I've been writing my routes like: ```typescript export const router = t.router({ helloWorl