在我的Repository里,为什么封装成一个方法后catch不到异常?
private fun <T> startFlow(param: T) = flow {
emit(Result.Loading)
emit(Result.Success(param))
}.flowOn(Dispatchers.IO)
.onStart {
emit(Result.Loading)
}.catch {
emit(Result.Error)
}
而这样就可以
suspend fun requestToeflList() = flow {
emit(Result.Loading)
emit(Result.Success(toeflService.requestToeflList()))
}.flowOn(Dispatchers.IO)
.onStart {
emit(Result.Loading)
}.catch {
emit(Result.Error)
}
有无大佬解决疑问