https://kotlinlang.org logo
#flow
Title
# flow
j

jdiaz

03/19/2020, 11:08 PM
I'm starting with flows (and coroutines). I'm trying to create a consumer of a flow that asynchronously executes a function. Would this approach work? https://pastebin.com/k00hWppm I still have some questions like: 1. Should the map of flows and the executor be in the same scope? 2. Would this scale? For example if i publish hundreds of thousands of "events" in the flows, would this become a problem as I'm launching many coroutines? As context this is for a load testing library that I'm playing around with
And something else: Should Channels be used in this case? The flow is literally Flow<Unit> as I just need to emit a signal for the next method to be executed and no parameters attached to it (at least for now). I thought flow would be easy as the actual code for it is just
Copy code
while (running) {
                delay(delay.delay)
                emit(Unit)
            }