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

myanmarking

07/01/2020, 9:49 AM
is it safe to write code like this:
Copy code
channelFlow {
    flowOf(1, 2, 3, 4)
        .map { delay(100); it }
        .collect { send(it) }
}
I mean, when the channelFlow get's cancelled, it also cancels the inner flow right ? Because both have the same scope
p

pedro

07/01/2020, 10:07 AM
Yes, both would be cancelled… but unless you oversimplified your example, I don’t understand why you need the outer flow
m

myanmarking

07/01/2020, 10:28 AM
was just for the purpose of demo. The example makes no sense obviously 😛 thanks
l

louiscad

07/01/2020, 10:40 AM
delay
is cancellable, so if the flow is suspended here during cancellation, it will be cancelled properly
3 Views