Is the only way to make a step in a flow concurren...
# coroutines
d
Is the only way to make a step in a flow concurrent by using flatMapMerge? I have a transform step that can be made concurrent (it uses network requests), can I just use a withContext on it?
d
If I understand your querstion right, my answer is: There is a async-version of
flow::map
flow::filter
flow::onEach
flow::transform
and others ... https://kotlinlang.org/docs/reference/coroutines/flow.html#terminal-flow-operators
d
The only one of those that has a
concurrency
parameter is
flatMapMerge
... which I think collects each flow it receives in another coroutine... but I was wondering if I could avoid that... I think this question was asked before a few times... there might have been some updates since though...?
Maybe this helps you
.flowOn(Dispatchers.Default)
d
That seems to create only one coroutine running on one other thread for the whole chain of operations before the collect. Whereas to have EACH one of the transforms run on a different coroutine, it wouldn't be sufficient as far as I understand...
d
d
Thanks for reminding me about that article 🙂 ...