Hi! I'm enabling processing of "events flow" based...
# coroutines
d
Hi! I'm enabling processing of "events flow" based on other 2 condition flows. I wonder if there's a more elegant/simpler way to write this chain (using if/else -> emptyFlow() feels edgy):
Copy code
combine(
  conditionFlow1, // Flow<Boolean>
  conditionFlow2,
  ::Pair
)
.flatMapLatest { (cond1, cond2) ->
  if (cond1 && cond2) eventSourceFlow.events else emptyFlow()
}
.onEach { event ->
  handleEvent(event)
}
.launchIn(scope)
p
transformLatest
Copy code
combine(
  conditionFlow1, // Flow<Boolean>
  conditionFlow2,
  ::Pair
)
.transformLatest { (cond1, cond2) ->
  if (cond1 && cond2) emitAll(eventSourceFlow.events)
}
.onEach { event ->
  handleEvent(event)
}
.launchIn(scope)
d
Niice, thank you!