My view model has a computed property - it forwards to an underlying model that does not know about the
MutableState
type. Is there a way to signal Compose when this computed property has changed, without keeping a separate copy of the data in my view model as a
MutableState
? (In SwiftUI I do this with
objectWillChange.send()
)
d
dewildte
10/18/2021, 7:42 PM
Can you give an example of how the data is being forwarded? A small code example perhaps?
z
Zach Klippenstein (he/him) [MOD]
10/19/2021, 4:52 PM
You could publish the property as a
StateFlow
, but why don’t you want to store a copy of the computed value? That value has to be in memory somewhere, and it would be a lot simpler to just publish the property via a
derivedStateOf
from your view model.
r
robnik
10/22/2021, 8:40 PM
I have a property on my viewmodel (for a settings screen) that looks like this: