buildKtorInfiniteQueryKey
inline fun <T, S> buildKtorInfiniteQueryKey(id: InfiniteQueryId<T, S>, crossinline fetch: suspend HttpClient.(param: S) -> T, noinline initialParam: () -> S, noinline loadMoreParam: (QueryChunks<T, S>) -> S?): InfiniteQueryKey<T, S>
A delegation function to build an InfiniteQueryKey for Ktor.
class GetUserPostsKey(userId: Int) : InfiniteQueryKey<Posts, PageParam> by buildKtorInfiniteQueryKey(
id = ..,
fetch = { param ->
get("https://jsonplaceholder.typicode.com/users/$userId/posts") {
parameter("_start", param.offset)
parameter("_limit", param.limit)
}.body()
},
...
)
Content copied to clipboard
Note: httpClient is required to use the builder functions designed for soil.query.core.ContextReceiver.
Parameters
id
The identifier of the infinite query key.
fetch
The query function that sends a request to the server.