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()
},
...
)

Note: KtorReceiver is required to use the builder functions designed for KtorReceiver.

Parameters

id

The identifier of the infinite query key.

fetch

The query function that sends a request to the server.