Hi :wave: I have scenario that looks very easy but...
# coroutines
t
Hi 👋 I have scenario that looks very easy but it is not. I have 2 flows. I need to react only on first flows events and that reaction use actual value from second flow. I need to do not react on second flow emits and first flow can emit same event multiple times (so no distinctUntilChanged). Does anyone know how to do it ? Thanks
j
distinctUntilChanged
has a version which takes a predicate that you can use to only compare the number value (in this example). So then it's just combime + distinctUntilChanged w/predicate.
Otherwise this is mostly known as
withLatestFrom
from Rx world, and has a first-party feature request: https://github.com/Kotlin/kotlinx.coroutines/issues/1498
👍 1
There are alternate implementations in that issue you can use. Basically collect both in parallel and grab the latest produced from the second whenever the first emits. Just remember to design the case where you get a number before a letter (in your example)
t
Thank you 🙇