Colton Idle
07/23/2024, 1:52 PMkevin.cianfarini
07/23/2024, 1:56 PMlaunchIn
.
launch {
flow.collect { item -> ... }
}
Joffrey
07/23/2024, 1:57 PMflow.onEach { doStuff(it) }.collect()
is equivalent to flow.collect { doStuff(it) }
• flow.launchIn(scope)
is equivalent to scope.launch { flow.collect() }
So... if you want to use launchIn
, you kind of have to go with onEach
, because you don't control the collect()
call anymore (you can't pass a lambda to it). I do tend to prefer scope.launch { flow.collect { ... } }
in general, but I don't have a very strong opinion on this, I guess it's a matter of style.
> I thought all of the "on*" operators were side-effecty
Well updateUI(event)
seems quite side-effecty to me 😄 It does seem to match what you expected herejw
07/23/2024, 2:39 PMupdateUI
is the direct effect, not a side effectJoffrey
07/23/2024, 5:14 PMRok Oblak
07/24/2024, 7:52 AMHristijan
07/24/2024, 12:34 PM