Hi everyone, I would like to know when the hang of...
# coroutines
c
Hi everyone, I would like to know when the hang of
channelFlow.collect
will resume? If there is a task in the
channelFlow
block that doesn’t know when it will complete, when will the coroutines channel close? I’m a little curious what the criteria is for the channel to determine
channelFlow
completion, is it to wait a while without any
send
and then end the hang?
s
c
@Sam Thank you, but I also want to understand how
channelFlow
resume works hahaha
s
Without
awaitClose
, the flow will terminate as soon as the code inside the builder is done executing. With
awaitClose
, it will run forever, until you explicitly stop collecting it. If you want anything different from those two options, you would need to implement it manually by calling
close()
on the channel inside the builder.
❤️ 1
c
This completely answered my questions!
s
In your Gradle example,
configureEach
just registers a callback that will be invoked "as each element is required", so it's likely that the flow would complete immediately, before the callback has been invoked on any of the items.