<div class='type'>Interface</div>


<a id='references'></a>

<div class='sourceset sourceset-common'>Common</div>



```kotlin
@JvmDefaultWithCompatibility
public interface SnapshotMutationPolicy<T>
```


A policy to control how the result of `mutableStateOf` report and merge changes to the state
object.

A mutation policy can be passed as an parameter to `mutableStateOf`, and `compositionLocalOf`.

Typically, one of the stock policies should be used such as `referentialEqualityPolicy`,
`structuralEqualityPolicy`, or `neverEqualPolicy`. However, a custom mutation policy can be
created by implementing this interface, such as a counter policy,


## Functions



<h2 id="equivalent-a-b">equivalent</h2>

```kotlin
public fun equivalent(a: T, b: T): Boolean
```


Determine if setting a state value's are equivalent and should be treated as equal. If
`equivalent` returns `true` the new value is not considered a change.




<hr class="docs-overload-divider">


<h2 id="merge-previous-current-applied">merge</h2>

```kotlin
public fun merge(previous: T, current: T, applied: T): T?
```


Merge conflicting changes in snapshots. This is only called if `current` and `applied` are
not `equivalent`. If a valid merged value can be calculated then it should be returned.

For example, if the state object holds an immutable data class with multiple fields, and
`applied` has changed fields that are unmodified by `current` it might be valid to return a
new copy of the data class that combines that changes from both `current` and `applied`
allowing a snapshot to apply that would have otherwise failed.