New article by <@U0PQ0GVLM>: Suspending functions ...
# feed
h
New article by @marcinmoskala: Suspending functions vs. Flow: When to use which? Choosing the right tool in Kotlin coroutines can keep your Android architecture clean, predictable, and easy to maintain. In this article, you’ll find a clear breakdown of when to use each — and why using Flow everywhere can lead to unnecessary complexity. 📄 https://kt.academy/article/suspend-vs-flow
s
Solid advice from Marcin. One other situation where you could use a Flow instead of a suspend function: A method that gets data in more than 1 step, using more than one (remote) data source, and some of these steps are quite slow, should return a Flow that emits each intermediate and updated result one step at a time. This would allow you to update the UI each "step" so that the user sees at least something at an earlier time.
👍 3
m
Yes, that is a great use-case for a flow. Emitting intermediete values so user can see results more quickly.