{% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %} {% include "_shared/_reference-head-tags.html" %}

SnapshotMutableState

public interface SnapshotMutableState<T extends Object> extends MutableState


A mutable value holder where reads to the value property during the execution of a Composable function, the current RecomposeScope will be subscribed to changes of that value. When the value property is written to and changed, a recomposition of any subscribed RecomposeScopes will be scheduled. Writes to it are transacted as part of the Snapshot system.

In general for correctness: Anything that is mutable, that is read during composition or written to during composition, should be a SnapshotMutableState.

See also
State
MutableState
mutableStateOf

Summary

Public methods

abstract @NonNull SnapshotMutationPolicy<@NonNull T>

A policy to control how changes are handled in a mutable snapshot.

Inherited methods

From androidx.compose.runtime.MutableState
abstract @NonNull T
abstract @NonNull Function1<@NonNull T, Unit>
abstract @NonNull T
abstract void
setValue(@NonNull T value)

Public methods

getPolicy

abstract @NonNull SnapshotMutationPolicy<@NonNull T> getPolicy()

A policy to control how changes are handled in a mutable snapshot.