Hi guys, another question of how are you using cor...
# coroutines
i
Hi guys, another question of how are you using coroutines... In the context of
clean architecture
, how you guys model the coroutines execution for use cases? You guys only mark the execute method with suspend and let the caller decide how to start the suspend function, or make the suspend function return a deferred or result?
v
Our team treats
suspend
as a part of a function contract and marks with it every function which potentially can do IO (http or database access), even if the current implementation of the function is blocking. That plays out very nicely when, for example, we update a framework and it re-implements some operation in an async way, all we have to do is to add an adapter in one place, and all the other code keeps working.
b
It’s probably best to only do
suspend
if your function is actually going to suspend — so if you choose to do IO, make sure it’s IO that can suspend and not just be marked suspend but actually be blocking
suspend
isn’t free