Say I'm writing an interface which declares a meth...
# coroutines
o
Say I'm writing an interface which declares a method that returns a result some time in the future. A deferred result. Now, the obvious way to go, as I see it (it's a deferred result after all) is to declare it like this:
fun foo(): Deferred<Int>
So, now the implementer would call
async<Int>(...)
and do its thing. I'm also thinking that I could achieve the same with this declaration:
suspend fun foo(): Int
The implementation would be different, of course, but the end result would be almost the same. So, here's my question: Should one of these be preferred over the other. If so, which one? And if the latter is preferred, what do I put for
context
when calling
async<Int>(/*What context?*/)