Skip to content

Instantly share code, notes, and snippets.

@takahirom
Created October 17, 2021 08:01
Show Gist options
  • Save takahirom/b5f6d2960a65945b13259939b45d669a to your computer and use it in GitHub Desktop.
Save takahirom/b5f6d2960a65945b13259939b45d669a to your computer and use it in GitHub Desktop.
fun <T> mutableStateOf(
value: T,
policy: SnapshotMutationPolicy<T> = structuralEqualityPolicy()
): MutableState<T> = createSnapshotMutableState(value, policy)
class ViewModel {
val state = mutableStateOf("init", object : SnapshotMutationPolicy<String> {
override fun equivalent(a: String, b: String): Boolean {
return a == b
}
override fun merge(previous: String, current: String, applied: String): String {
return applied
}
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment