Hello, it looks like there's no built-in way to co...
# compose
l
Hello, it looks like there's no built-in way to convert a
State<T>
into a remembered
StateFlow<T>
. Is there any reason why? My use case is using flow operators along with computations I want to run off the UI thread before I convert them back into a
State
.
n
I think it's the role of
snapshotFlow { state }
? you'll need the
.stateIn
though, but I'm not sure there is a way around that because of how StateFlow works here
☝🏻 1
the produceState could help too,
Copy code
val listOfData = produceState(initialValue = emptyList<String>()) {
        snapshotFlow { key }.debounce(1_000L).flatMapLatest { key ->
            viewModel.getData(key)
        }.collectLatest {
            listOfData ->
            value = listOfData
        }
    }
2