martypitt
10/06/2023, 7:20 AMsuspend fun doSomething():Flux<T>
ie., a Suspend function, that returns a reactive type. (Returning a Flux<>
instead of a flow is a conscious choice, but suspend
is a mis-step).
We know we need to fix this, but this pattern is in heavy usage throughout the code. My question is:
What are the negative impacts of this pattern? Is this likely to be causing any performance issues?
ThxSam
10/06/2023, 7:38 AMSam
10/06/2023, 7:39 AMfun getFlow() = flow {
emitAll(getFlowFromSuspendingFunction())
}
ephemient
10/06/2023, 7:41 AMsuspend fun
with no suspend points shouldn't have a performance penalty at runtime (aside from the extra context passed through), as Kotlin skips creating the state machine when it is unnecessaryephemient
10/06/2023, 7:43 AMmartypitt
10/06/2023, 7:43 AM