https://kotlinlang.org logo
#coroutines
Title
# coroutines
j

jean

03/27/2023, 6:44 AM
I have the following test, which fails. It seems like the update done by one flow does not affect the other one. Is this a case where I should use a
Channel
to be able to communicate data between coroutines?
r

rkeazor

03/27/2023, 12:25 PM
Umm I would just write 2 tests. One test testing the first flow transmission and the 2nd one testing the second flow transmission. And just turn the flow into a list and check the first 2 elements..
n

natario1

03/27/2023, 10:18 PM
You can use a single
MutableStateFlow
and
launch
two coroutines writing into it. Values can be updated with
flow.update { ... }
so you get the old state and can copy it.
4 Views