MutableState

interface MutableState<T>(source)

A mutable value holder that can be observed for changes.

This interface allows for creating properties that, when their value changes, can trigger updates or reactions in other parts of the application.

It utilizes Kotlin's delegated property mechanism, allowing for concise syntax when declaring and using observable properties.

Example usage:

class MyViewModel {
var name: String by mutableStateOf("Initial Name")
}

// To observe changes (implementation details would depend on the specific
// observation mechanism used with MutableState):
// viewModel.observeName { newName -> println("Name changed to: $newName") }

// To change the value:
// viewModel.name = "New Name" // This would trigger observers.

Parameters

T

The type of the value held by this state.

Inheritors

Functions

Link copied to clipboard
abstract operator fun getValue(thisRef: Any?, prop: KProperty<*>): T
Link copied to clipboard
abstract operator fun setValue(thisRef: Any?, prop: KProperty<*>, value: T)