so i have this code that fetches data, typical use...
# coroutines
o
so i have this code that fetches data, typical usecases that fetch data from an API upon starting a viewmodel
Copy code
var location = mutableStateOf<GetLocation.Location?>(null)
var dateRange = mutableStateOf<DateRange?>(null)
var category = mutableStateOf(Category.All)
var period = mutableStateOf(Period.Any)

fun fetchData() {
    viewModelScope.launch(<http://dispatchers.io|dispatchers.io>) {
        getLocation.execute().fold(
            onSuccess = { response ->
                withContext(dispatchers.main) {
                    location.value = response.orNull()
                }
            },
            onFailure = {
                logger.log(it)
            }
        )
.... etc....
but I would like to observe any changes in these fields and fetch again when they’ve been updated is there like a combineLatest?
I think they will have to become MutableStateFlow first
so it’s basically
flowOf(flow1, flow2, flow3, flow4).flattenMerge().collect { actOnIt() }