Open xuningForAndroid opened 4 years ago
挂起函数 只能在 协程范围内调用
---原始邮件--- 发件人: "xuningForAndroid"<notifications@github.com> 发送时间: 2020年5月28日(周四) 晚上6:34 收件人: "sange93/MVPDemo"<MVPDemo@noreply.github.com>; 抄送: "Subscribed"<subscribed@noreply.github.com>; 主题: [sange93/MVPDemo] RetrofitManagerKt 类中request方法有错误 (#1)
deferred.await(),提示suspension functions can be called only within coroutine body,不能通过编译,请问什么原因
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.
那这应该怎么写?
/**
你的Presenter文件,有没有从Activity 把协程域传递给Presenter?
参考下:
class AddressListPresenter(scope: CoroutineScope) : BasePresenterKt
override fun deleteAddress(id: String, position: Int) = launch {
val map = HashMap<String, Any>()
map["id"] = id
RetrofitManagerKt.request(RetrofitManagerKt.apiService.requestAsync(map), true, mContext)?.also {
if (it.code == 0) {
mView?.deleteAddressSuccess(position)
} else {
ToastUtils.showShort(it.message)
}
}
}
} ———————————————— 版权声明:本文为CSDN博主「小石头93」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。 原文链接:https://blog.csdn.net/sange77/article/details/102575852
deferred.await(),提示suspension functions can be called only within coroutine body,不能通过编译,请问什么原因