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

Canato

08/12/2020, 7:35 PM
If I open a Flow inside a Channel this will block the channel for new events? or the flow will be existing in another thread/context?
z

Zach Klippenstein (he/him) [MOD]

08/12/2020, 7:38 PM
What do you mean by “inside a Channel”?
c

Canato

08/12/2020, 7:42 PM
I have a channel running where I threat my events. If one of this events open a Flow this would block my channel to receive new events? I could explain my self? if not let me know 🤔
z

Zach Klippenstein (he/him) [MOD]

08/12/2020, 7:56 PM
Not sure what you mean by running. A channel is a queue, it doesn't have the concept of running. Do you mean a coroutine created with
produce
?
c

Canato

08/12/2020, 9:03 PM
I normally use the channel with an loop inside for events this keep checking for events in the cue, So this loop keep running/executing Indeed, the channel coroutine is created by
produce
or
launch
z

Zach Klippenstein (he/him) [MOD]

08/12/2020, 9:07 PM
If you have a loop like this:
Copy code
for (value in channel) {
  flow.collect { … }
}
Then you won’t receive the next item from the channel until the flow completes. If something is sent to the channel, then it will be buffered according to the channel’s capacity, or suspend.
👍🏾 3
👏 1
c

Canato

08/13/2020, 7:41 AM
Thanks @Zach Klippenstein (he/him) [MOD] this was my doubt =D
2 Views