louiscad
10/13/2021, 10:10 AMState<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
.nitrog42
10/13/2021, 10:19 AMsnapshotFlow { state }
?
you'll need the .stateIn
though, but I'm not sure there is a way around that because of how StateFlow works herenitrog42
10/13/2021, 10:23 AMval listOfData = produceState(initialValue = emptyList<String>()) {
snapshotFlow { key }.debounce(1_000L).flatMapLatest { key ->
viewModel.getData(key)
}.collectLatest {
listOfData ->
value = listOfData
}
}