avallete
avallete
Explore posts from servers
TtRPC
Created by avallete on 6/22/2023 in #❓-help
infiniteQuery always undefined cursor
Pretty sure this is not the right solution, but as a workaround I did that:
const liveLogsQuery = trpc.execTask.getLogs.useInfiniteQuery(
{
execTaskId: execTaskResult.execTask.id,
debug: execTaskResult.isAdmin,
},
{
getNextPageParam: (lastPage) => lastPage.nextCursor,
}
)

React.useEffect(() => {
const interval = setInterval(() => {
if (liveLogsQuery.hasNextPage && tailLog) {
liveLogsQuery.fetchNextPage()
}
}, 3000)
return () => {
clearInterval(interval)
}
}, [liveLogsQuery.fetchNextPage, liveLogsQuery.hasNextPage, tailLog])
const liveLogsQuery = trpc.execTask.getLogs.useInfiniteQuery(
{
execTaskId: execTaskResult.execTask.id,
debug: execTaskResult.isAdmin,
},
{
getNextPageParam: (lastPage) => lastPage.nextCursor,
}
)

React.useEffect(() => {
const interval = setInterval(() => {
if (liveLogsQuery.hasNextPage && tailLog) {
liveLogsQuery.fetchNextPage()
}
}, 3000)
return () => {
clearInterval(interval)
}
}, [liveLogsQuery.fetchNextPage, liveLogsQuery.hasNextPage, tailLog])
3 replies
TtRPC
Created by avallete on 4/16/2023 in #❓-help
query debounce
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 ?
6 replies