Vivek Modi
05/04/2022, 2:28 PMclass KtorCountryApi : NetworkRoute(), KoinComponent {
private val httpClient by inject<HttpClient>()
suspend fun getCountry(): ApiResponse<KtorCountriesResponse> {
val response = httpClient.get {
url("xyz")
}
return apiCall(response)
}
}
NetworkRoute
open class NetworkRoute {
suspend inline fun <reified T : Any> apiCall(httpResponse: HttpResponse): ApiResponse<T> {
return try {
ApiResponse.Success(httpResponse.body())
} catch (e: Exception) {
ApiResponse.Error()
}
}
}
when I am calling in ios code
let ktorApi = KtorCountryApi()
ktorApi.getCountry()
I am getting weird issue 'async' call in a function that does not support concurrency
ribesg
05/05/2022, 8:01 AMsuspend
Kotlin functions are exposed as the Swift async
thingies, so you need to use that on the Swift side https://docs.swift.org/swift-book/LanguageGuide/Concurrency.htmlVivek Modi
05/05/2022, 12:50 PM