From f686be0b538211416fae578a38ad8e3fd8b36adf Mon Sep 17 00:00:00 2001 From: Alejandro Nijamkin Date: Mon, 27 Mar 2023 08:52:49 -0700 Subject: [PATCH] Further simplification of collectValues. Bug: 274159734 Test: N/A Change-Id: Ida3fef1ae465f492241660af1d1518a1d0233496 --- .../src/com/android/systemui/coroutines/Flow.kt | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/coroutines/Flow.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/coroutines/Flow.kt index e1ba074ac860d..ce8d93e2a0e78 100644 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/coroutines/Flow.kt +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/coroutines/Flow.kt @@ -69,10 +69,10 @@ fun TestScope.collectValues( flow: Flow, context: CoroutineContext = EmptyCoroutineContext, start: CoroutineStart = CoroutineStart.DEFAULT, -): FlowValues { +): FlowValue> { val values = mutableListOf() backgroundScope.launch(context, start) { flow.collect(values::add) } - return FlowValuesImpl { + return FlowValueImpl { runCurrent() values.toList() } @@ -83,17 +83,7 @@ interface FlowValue : ReadOnlyProperty { operator fun invoke(): T } -/** @see collectValues */ -interface FlowValues : ReadOnlyProperty> { - operator fun invoke(): List -} - private class FlowValueImpl(private val block: () -> T) : FlowValue { override operator fun invoke(): T = block() override fun getValue(thisRef: Any?, property: KProperty<*>): T = invoke() } - -private class FlowValuesImpl(private val block: () -> List) : FlowValues { - override operator fun invoke(): List = block() - override fun getValue(thisRef: Any?, property: KProperty<*>): List = invoke() -}