Hildebrandt Tobias
06/19/2025, 9:34 PMuseQuery<Array<DocumentationElementDto>?, Error, Array<DocumentationElementDto>, QueryKey>(
options = UseQueryOptions(
queryKey = DOCUMENTATION_QUERY_KEY.plus(subCategory),
queryFn = QueryFunction {
secureApi(DocumentationEndpoints
.getDocumentationElement
.copy(optionalQueryParams = pairListOf("category" to subCategory))
)},
refetchOnMount = { _ -> false },
refetchOnWindowFocus = { _ -> false },
refetchOnReconnect = { _ -> false },
refetchInterval = 0,
refetchIntervalInBackground = false,
)
)
In this case
refetchOnMount = { _ -> false },
refetchOnWindowFocus = { _ -> false },
refetchOnReconnect = { _ -> false },
doesn't work, but these two:
refetchInterval = 0,
refetchIntervalInBackground = false,
behave as expected.
I also tried useCallback { _ -> false }
, but it isn't accepted by the compiler.turansky
06/20/2025, 11:26 AM// file constant
val NO_REFETCH = { _: Any? -> false }
refetchOnMount = NO_REFETCH,
refetchOnWindowFocus = NO_REFETCH,
refetchOnReconnect = NO_REFETCH
?Hildebrandt Tobias
06/20/2025, 12:09 PMturansky
06/20/2025, 12:51 PMHildebrandt Tobias
06/20/2025, 1:37 PMHildebrandt Tobias
06/20/2025, 1:53 PM{ _ -> false}
works. It just doesn't show up in the debugger.
Other fields had filled functions depicted with this: { }
I had two useQuery
with the same key and I wrongly assumed that with these options the according
observer wouldn't update when the underlying QueryKey
updates.
So one observer had the options and the other didn't, but the one that didn't still got the update pushed when the observer with refetch still enabled triggered the refetch.
Sorry, that behaviour was kind of unexpected for me.