I have a question about Fx. The docs talk about us...
# arrow
j
I have a question about Fx. The docs talk about using
suspend
to signal side-effecty functions. When I do this my IDE gives me helpful hints saying I don’t need the
suspend
keyword since I don’t call any suspend functions. Is there a typical solution for this? Do I just suppress / annotate it away?
r
Hi @Jeff, yeah that’ s annoying because Kotlin does not consider effects like
println
or file
io
as needing suspension but in whatever case I found that most of those functions should instead be inline. If they are inline they work both in pure contexts but also in suspended ones where their body get fully inlined in the caller site. There is already in the scope of a continuation and can properly handle errors in the effect that are thrown.
Do you have an example of the function you are seeing this?
j
I can’t remember where I was seeing it last but I’m in an Android environment so it was something like writing to shared preferences (key value store on disk).
s
If you use jetpack Data Store, those calls have to be suspend...
👌 4