I’m refactoring one interface to change function f...
# coroutines
j
I’m refactoring one interface to change function from suspend to simple. Any ideas how this can be done? Current:
Copy code
Inteface T { suspend fun A: String}

Class S{
  suspend fun B(){
    val result = t.A() 
}
}
I want to change fun A to return Deferred<String> object, but not sure how to change
val result = t.A()
so the result would be the same as if A was suspend function.
j
I think
val result = t.A().await()
is what you are looking for?
j
thanks, I’ll try that
z
Why do you want A to return a deferred though? It's generally a better practice to write functions as suspend functions and let callers wrap them with
async
if they need it.
j
it’s an interface that should be implemented in swift, where suspend functions are not exported