Lilly
05/11/2022, 1:12 AMSnapshotStateMap<String, Any>
and storing the value in a state object:
// viewmodel content
private val state: SnapshotStateMap<String, Any> = mutableStateMapOf()
var myState by mutableStateOf(StateObject(state.getValue("key")))
@Immutable
data class StateObject(val value: Any)
I'm changing the values by bubbling up a onValueChange
event that accesses state
like state["key"] = newValue. But when I use for example a Slider
composable and onValueChange
is triggered, the Slider does not reflect the change, although I can print the new values. I guess storing the value in a state object as intermediate step is the problem. Is this intended or do I miss something here?natario1
05/11/2022, 2:23 AMval keyState by remember(state) {
derivedStateOf { StateObject(state.getValue("key")) }
}
Assuming you really need this intermediate step.