i've noticed that with asynchronous programming i ...
# announcements
l
i've noticed that with asynchronous programming i quickly end up making almost every function in my code
suspend
. is that a sign of bad code or is this normal? i've read somewhere that at least in C# "async everything" is pretty common but im not sure if that applies to kotlin as well
l
I don't usually have that. Most of my functions are non-suspend, and I only suspend when going async, but I don't exactly program "asyncronous programming"
s
Don't make every function
suspend
. There's overhead related to making one
suspend
. Do it only when needed.
g
It's fine if most of your code asyncronous, just do not mark code that non asyncronous as suspend, it's useless and you just pay overhead
Hah, yeah, exactly what Anton said, he was faster 😅
s
It’s a bit different if you are using Arrow and their Fx library; any function that is not pure should be annotated as
suspend
. 🙂 arrow