instead of `while / try / receive` you can just us...
# coroutines
b
instead of
while / try / receive
you can just use a
for
loop over
channel
. As for testing,
runBlocking
is generally used to make the function wait until the coroutines are done.
k
Yes I have changed it to use
consumeEach
to not have to handle the close excpetion myself. But the question how to test this remains. I am using
runBlocking
but I have an issue regarding the timing of mocking
send
events to the
channel
and the assertion on the
LiveData
instance. @elizarov Do you have some suggestion on this?
Ok I tried it with mocking the channel using a buffered
channel
and after the mocked
send
calls I use
close
and it works. I didnt knew that
close
waits all items to be consumed before closing the channel