In Jetpack Compose, if I have a MutableState
variable, I can expose it's State as "read-only" value to other classes as State<String>
, just like:
private val _title = mutableStateOf("abc")
val title: State<String> = _title
Is there a way to do this with SnapshotStateList<>
too? How would I do this for example with:
private val _titles = mutableStateListOf<String>(...)
val titles: ??? = _titles
I know that I could work around this by just using MutableState<List<String>>
, but I'd have to provide a whole new list every time I would want to add/remove items.
titles
in a composable, compose would know there's a State-object behind that to observe and still recomposes when_titles
changes? – Disgust