remember

fun <T> ViewScope.remember(key: String, calculation: () -> T): T(source)

Remembers a value computed by calculation.

The value is stored in the ViewScope cache and will be reused across re-renders as long as the key remains the same.


fun <T> ViewScope.remember(key: String, input: Any?, calculation: () -> T): T(source)

Remembers a value computed by calculation, recomputing it only if input changes.

Parameters

key

A unique identifier for this cached value.

input

A dependency that triggers recomputation when its value changes.

calculation

The logic to produce the value.