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()
}
)
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 query key.
fetch
The query function that sends a request to the server.