google / horologist

Horologist is a group of libraries that aim to supplement Wear OS developers with features that are commonly required by developers but not yet available.
https://google.github.io/horologist/
Apache License 2.0
575 stars 95 forks source link

Update CombinedInferenceServiceRegistry.kt #2420

Closed GeorgCantor closed 1 month ago

GeorgCantor commented 1 month ago

WHAT

Use flatMap for Combining Flows: Instead of using combine and then flattening the result, we can use flatMapConcat, which is more efficient for this use case.

WHY

Performance Improvement: Using flatMapConcat is generally more efficient than combining and flattening lists afterward.

HOW

Checklist :clipboard:

yschimke commented 1 month ago

It's not compiling


> Task :ai:sample:core:compileDebugKotlin FAILED
e: file:///home/runner/work/horologist/horologist/ai/sample/core/src/main/java/com/google/android/horologist/ai/core/registry/CombinedInferenceServiceRegistry.kt:27:27 Unresolved reference 'asFlow'.
e: file:///home/runner/work/horologist/horologist/ai/sample/core/src/main/java/com/google/android/horologist/ai/core/registry/CombinedInferenceServiceRegistry.kt:28:30 Cannot infer type for this parameter. Please specify it explicitly.
e: file:///home/runner/work/horologist/horologist/ai/sample/core/src/main/java/com/google/android/horologist/ai/core/registry/CombinedInferenceServiceRegistry.kt:28:51 Unresolved reference 'models'.
e: file:///home/runner/work/horologist/horologist/ai/sample/core/src/main/java/com/google/android/horologist/ai/core/registry/CombinedInferenceServiceRegistry.kt:30:14 Unresolved reference 'asFlow'.
yschimke commented 1 month ago

But generally the new logic seems different anyway.