buildKtorMutationKey

inline fun <T, S> buildKtorMutationKey(id: MutationId<T, S> = MutationId.auto(), crossinline mutate: suspend HttpClient.(variable: S) -> T): MutationKey<T, S>

A delegation function to build a MutationKey for Ktor.

class CreatePostKey : MutationKey<Post, PostForm> by buildKtorMutationKey(
mutate = { body ->
post("https://jsonplaceholder.typicode.com/posts") {
setBody(body)
}.body()
}
)

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

Parameters

id

The identifier of the mutation key.

mutate

The mutation function that sends a request to the server.