https://kotlinlang.org logo
Title
a

Andrew Gazelka

06/02/2019, 1:54 AM
wait why is this?
g

gildor

06/02/2019, 2:15 AM
Because sequence is syncronous only abstraction
Consumer can use it from non-suspend function
There is no API in sequence to consume values asyncronously
So this is the reason, why only yield suspend function is allowed in sequence builder, to avoid confusion when one may accidentally block caller thread by invoking some arbitrary suspend function
a

Andrew Gazelka

06/02/2019, 2:19 AM
ah ok that makes sense
g

gildor

06/02/2019, 2:19 AM
If you need fully async streams, use kotlinx.coroutines Flow, which may be consumed only from suspend function
Sorry, suspend -> sequence in my first message
Suspend of course asyncronous, but sequence is syncronous, but lazy, same way as Java streams