Andrey Stepankov
03/16/2020, 5:04 PMZach Klippenstein (he/him) [MOD]
03/16/2020, 5:15 PMlouiscad
03/16/2020, 8:17 PMtake
operator: https://flowmarbles.com/#takeZach Klippenstein (he/him) [MOD]
03/16/2020, 8:38 PMlouiscad
03/16/2020, 9:03 PMtake
, as shown in the screenshot per your request (now deleted), and more importantly, as implemented and specified in the documentation.
Talking about the doc, there's online KDoc, it'd be really good to link it, and possibly embed it as a bonus (with an iframe to ensure it's up to date).
https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/take.htmlAndrey Stepankov
03/16/2020, 9:15 PMlouiscad
03/16/2020, 9:28 PMemit
.
The first is easy to show and very important because it's very common.
The second is important as soon as there's suspension in the collector (including intermediate operators). It requires some rethinking in how it's shown in the visualization.
The diagrams we can see on the screenshot I annotated above work only if you're using `flowOf`(element1, element2, ...)`.
In real-life, Flows are not hardcoded and some cancellable suspending function will be suspending between collection of elements, or emission of elements (on the collector side).
So, I believe over-simplified diagrams do not help understanding the important details like the two ones I've been mentioning.Andrey Stepankov
03/16/2020, 9:35 PM