I have an api that provides 2 ways of calling a me...
# coroutines
d
I have an api that provides 2 ways of calling a method. One returns Future (plain java future) and another one accepts callback. Which way is better to convert it to suspendable function? 1. Wrap call into withContext(Distpatcher.IO) { future.get() } 2. Wrap callback with a suspendCoroutine{ } method I prefer second option, because it looks more idiomatic, but withContext looks cleaner for a person less familiar with coroutines
g
100% suspendCoroutine
a person less familiar with coroutines
But no need to expose it, you just should write an adapter for this API that based on callbacks, so user of this API can just call it, without additional wrapper
d
that's true
👍