android - Kotlin Flow 的手动重试
问题描述
如果您已将错误处理委托给扩展函数,是否有办法在 Kotlin 中手动重试失败的流程。
我发布了一个类似的问题:Kotlin Flow, callback
如果我的流程的errorHandle 是下面的那个。
fun <T> Flow<T>.handleErrors(showError: Boolean = false, retry: Boolean = false,
navigateBack: Boolean = true): Flow<T> =
catch { throwable ->
var message: String? = null
if (showError) {
when (throwable) {
is HttpException -> {
postEvent(EventType(retry))
}
}
}
如何使用流手动重试失败的 api 调用。
解决方案
推荐阅读
- r - 有没有办法在 R 中定义“原始”字符串?
- vba - 如何使用vba从数据表中检索特定记录
- javascript - 如何在asp中获取n个数字输入类型的表格行的值?
- c# - ASP.NET Core Web API:xmlns 不是预期的
- bootstrap-4 - 如何设置 th:来自片段的属性
- python - 在 python 3 中记录 imodule 的 UTF-8 编码问题
- spring-boot - 如何配置 springfox 以解包响应类型,例如 Mono 和 Flux,而无需在 @ApiResponse 中显式指定响应类型
- python-3.x - 想不出办法让这段代码正确
- java - 即使将新数组长度设置为旧数组长度,也会出现 ArrayIndexOutOfBoundsException
- sql-server-2017 - 如果有空格,则首字母应为大写