buildKtorQueryKey

inline fun <T> buildKtorQueryKey(id: QueryId<T>, crossinline fetch: suspend HttpClient.() -> T): QueryKey<T>

A delegation function to build a QueryKey for Ktor.

class GetPostKey(private val postId: Int) : QueryKey<Post> by buildKtorQueryKey(
id = ..,
fetch = {
get("https://jsonplaceholder.typicode.com/posts/$postId").body()
}
)

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

Parameters

id

The identifier of the query key.

fetch

The query function that sends a request to the server.