https://kotlinlang.org logo
Title
n

nitrog42

04/20/2020, 2:38 PM
flow {
    while (true) {
        delay(1000)
        emit(Unit)
    }
}
?
👍 1
:yes: 2
s

streetsofboston

04/20/2020, 2:40 PM
That is the cool thing about coroutines (and Flows). You can code your own special flow behaviors, operators, etc in a very imperative/sequential way. 🙂
n

nitrog42

04/20/2020, 2:40 PM
hehe yeah that is almost too easy honnestly
😄 1
l

louiscad

04/20/2020, 9:16 PM
Note that this cannot be used for a timer because it doesn't take into account the execution time delay adding up, nor emit taking some time to resume (because the lambda of collect would take some time).
j

Jörg Winter

04/21/2020, 7:24 AM
Hi, coming over from another Slack-Thread about internal "collect" vs.
launchIn {}
, just to be clear on flow consumption: the canonical way to consume is: a) toList() b) launchIn(...) .. else ?