Thomas
07/08/2024, 3:06 AMState<ListT> to SnapshotStateListT?
The best I could come up with is this, but it feels stupid, I wonder if there is a better way.
val a: State<ListT> = viewModel.collectAsStateWithLifecycle(initialValue = emptyList())
val b: SnapshotStateListT by remember{
derivedStateOf {
mutableStateListOfT().apply {
addAll(a.value)
}
}
}
(note that when the original State<ListT> updates, the SnapshotStateListT should also update)