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

Tianyu Zhu

10/07/2023, 5:20 PM
Is it weird to have a non-suspending function that takes a
CoroutineScope
and returns a
Flow
? e.g.,
Copy code
fun CoroutineScope.getMyStuffs(): Flow<MyStuff>
k

kevin.cianfarini

10/07/2023, 5:31 PM
This is what
Flow.stateIn
does
j

jw

10/07/2023, 5:44 PM
It's a little weird. What is the scope used for? Why can't you use a scope within the flow collection?
☝🏻 1
☝️ 4
p

Patrick Steiger

10/07/2023, 8:37 PM
Agreed it’s weird, because this suggests something that could outlive the flow collection Otherwise a scope limited to flow collector would look like
Copy code
flow { 
  coroutineScope {
  }
}
Or
channelFlow
👍 3
💯 1
2 Views