1

I have currently two SharedFlows that I need to combine to do something, but I don't really need the result from the transformation function, I only want to know if both "events" started yet. While implementing this I get this useless bracket body:

combine(
  flow1, // SharedFlow<Unit>
  flow2, // SharedFlow<Unit>
) { _, _ ->

  // Useless function body

}.onEach {
  // Do some work
}.launchIn(scope)

Is there a way I can do this more cleanly without the need for the transform function?

Sergio
  • 27,326
  • 8
  • 128
  • 149
Pedro Romano Barbosa
  • 587
  • 3
  • 11
  • 29

1 Answers1

3

You can "Do some work" in "Useless function body" instead of onEach:

combine(
  flow1, // SharedFlow<Unit>
  flow2, // SharedFlow<Unit>
) { _, _ ->

  // Do some work

}.launchIn(scope)
Sergio
  • 27,326
  • 8
  • 128
  • 149