[英]Type mismatch. Required: suspend () → Response<*> Found: Response<Void>
In my android app the two methods getTraidersList
and executeTraderOperation
must return type TransportResponse
在我的 android 应用程序中,两个方法
getTraidersList
和executeTraderOperation
必须返回类型TransportResponse
Snippet:片段:
interface TraderMonitorRestClient {
@GET("traders/json")
suspend fun getTraidersList(): Response<List<Trader>>
@GET("trader/{trader_operation}")
suspend fun executeTraderOperation(@Path("trader_operation") traderOperation: String,
@Query("base") base: String,
@Query("quote") quote: String,
@Query("sender") sender: String,
@Query("key") key: String): Response<Void>
}
suspend fun getTraidersList(): TransportResponse = withContext(Dispatchers.IO) {
val traderMonitorRestClient = RestClientFactory.createRestClient(TraderMonitorRestClient::class.java)
executeOperation(traderMonitorRestClient.getTraidersList())
}
suspend fun executeTraderOperation(traderOperation: Trader.Operation, base: String, quote: String): TransportResponse = withContext(Dispatchers.IO) {
val traderMonitorRestClient = RestClientFactory.createRestClient(TraderMonitorRestClient::class.java)
val sender = BuildConfig.APPLICATION_ID + "_" + BuildConfig.VERSION_NAME
val key = DateUtil.getDateAsString(Date(), "mmHHddMMyyyy")
executeOperation(traderMonitorRestClient.executeTraderOperation(traderOperation.toString().toLowerCase(), base.trim(), quote.trim(), sender, key))
}
suspend private fun executeOperation(someFunction: suspend () -> Response<*>): TransportResponse {
try {
val response: Response<*> = someFunction()
return onResponse(response)
} catch (e: Throwable) {
return onNetworkFailure(e)
}
}
But I get compile errors in this lines:但是我在这一行中遇到编译错误:
executeOperation(traderMonitorRestClient.getTraidersList())
error message:错误信息:
Type mismatch.
Required:
suspend () → Response<*>
Found:
Response<List<Trader>>
and here和这里
executeOperation(traderMonitorRestClient.executeTraderOperation(traderOperation.toString().toLowerCase(), base.trim(), quote.trim(), sender, key))
error message:错误信息:
Type mismatch.
Required:
suspend () → Response<*>
Found:
Response<Void>
用
executeOperation {traderMonitorRestClient.getTraidersList() }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.