MutatedEffect

fun <T, U : Any> MutatedEffect(mutation: MutationObject<T, *>, keySelector: (MutationSuccessObject<T, *>) -> U, keySaver: Saver<U?, out Any> = autoSaver(), block: suspend (data: T) -> Unit)

A Composable function to trigger side effects when a Mutation is successfully processed.

By using this function, you can receive the result of a successful Mutation via block. This is particularly useful when working with MutationObject.mutateAsync.

Parameters

T

Type of the return value from the mutation.

U

Type of the key to identify whether the Mutation has already been handled.

mutation

The MutationObject whose result will be observed.

keySelector

A function to calculate a key to identify whether the Mutation has already been handled. The key is compared upon the next success.

keySaver

A Saver to persist and restore the last consumed key.

block

A callback to handle the result of the Mutation. This is called only when the key differs from the previous one.


inline fun <T> MutatedEffect(mutation: MutationObject<T, *>, noinline block: suspend (data: T) -> Unit)

A Composable function to trigger side effects when a Mutation is successfully processed.

This function uses MutationObject.mutatedCount as the key. If you need to use a different key, use MutatedEffect with the keySelector parameter.

NOTE: If Mutation optimization is enabled, you must explicitly specify a keySelector. This is because MutationObject.mutatedCount is omitted during optimization and will always be 0.

Parameters

T

Type of the return value from the mutation.

mutation

The MutationObject whose result will be observed.