Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0f00b3b7 authored by Steve Elliott's avatar Steve Elliott
Browse files

[kairos] delete redundant combineValues util

The existing TState.combine() combinator does the same thing and is more
efficient.

Flag: EXEMPT unused
Test: m kairos
Change-Id: I59c7ea5d6f55b7223a907d159a29e30ab7559e62
parent 0f7868f9
Loading
Loading
Loading
Loading
+0 −10
Original line number Diff line number Diff line
@@ -69,16 +69,6 @@ fun <A, B, C> TFlow<A>.samplePromptly(
            }
        }

/**
 * Returns a [TState] containing a map with a snapshot of the current state of each [TState] in the
 * original map.
 */
fun <K, A> Map<K, TState<A>>.combineValues(): TState<Map<K, A>> =
    asIterable()
        .map { (k, state) -> state.map { v -> k to v } }
        .combine()
        .map { entries -> entries.toMap() }

/**
 * Returns a cold [Flow] that, when collected, emits from this [TFlow]. [network] is needed to
 * transactionally connect to / disconnect from the [TFlow] when collection starts/stops.
+2 −2
Original line number Diff line number Diff line
@@ -1170,12 +1170,12 @@ class KairosTests {
                                    mergeIncrementally
                                        .onEach { println("patch: $it") }
                                        .foldMapIncrementally()
                                        .flatMap { it.combineValues() }
                                        .flatMap { it.combine() }
                                }
                            }
                        }
                        .foldMapIncrementally()
                        .flatMap { it.combineValues() }
                        .flatMap { it.combine() }

                accState.toStateFlow()
            }