Hello! Is there a way to wait for an update on a l...
# flow
v
Hello! Is there a way to wait for an update on a list of flows to generate another flow? for example, these could be stateflows of integers, one per resource, and I'd like to generate a flow which is the resource associated with the current maximum integer
w
Something like this?
Copy code
fun foo(
    ints1: Flow<Int>,
    ints2: Flow<Int>,
    ints3: Flow<Int>,
) = combine(ints1, ints2, ints3) { ints -> ints.maxOf { it } }
    .distinctUntilChanged()
    .flatMapLatest { currentMax -> getResource(currentMax) }

fun getResource(int: Int): Flow<String> = TODO()
v
sort of yes, except its a stateflow and you cannot get the associated resource from the maximum alone, but I think your answer helps out, thanks 🙂
thanks !