getValue
Function
Common
public inline operator fun DoubleState.getValue(thisObj: Any?, property: KProperty<*>): Double
Permits property delegation of val
s using by
for DoubleState
.
Common
public inline operator fun FloatState.getValue(thisObj: Any?, property: KProperty<*>): Float
Permits property delegation of val
s using by
for FloatState
.
Common
public inline operator fun <T> State<T>.getValue(thisObj: Any?, property: KProperty<*>): T
Permits property delegation of val
s using by
for State
.
Common
public inline operator fun IntState.getValue(thisObj: Any?, property: KProperty<*>): Int
Permits property delegation of val
s using by
for IntState
.
Common
public inline operator fun LongState.getValue(thisObj: Any?, property: KProperty<*>): Long
Permits property delegation of val
s using by
for LongState
.
Code Examples
DelegatedReadOnlyStateSample
@Composable
fun DelegatedReadOnlyStateSample() {
// Composable function that manages a subscription to a data source, returning it as State
@Composable fun observeSampleData(): State<String> = TODO()
// Subscription is managed here, but currentValue is not read yet
val currentValue by observeSampleData()
Row {
// This scope will recompose when currentValue changes
Text("Data: $currentValue")
}
}