When using a ComposeView in an activity, is there a way to detect changes to activity variables?
Copy code
private val myState: State = State(value = 0)
someListener.onChange { value -> myState.value = value}
binding.composeView.setContent {
MyComposeView(
state = myState.value // Not recomposing on value changed
)
}
s
shikasd
01/17/2024, 8:46 PM
are you using
mutableStateOf
? what kind of state is
myState
?
b
Billy Newman
01/17/2024, 8:52 PM
State is a simple POJO. Also tried with mutableState in activity w/o luck.
s
shikasd
01/17/2024, 9:16 PM
you need to use
mutableStateOf
in this case and then it should work
regular objects are not observed by composition, while states are