0

使用 IO 时,我可以在 fx 块中使用continueOndispatchers.io()Dispatchers.IO可以混合使用。有首选方法吗?两者有什么区别吗?

注意:我也在使用协程集成来运行 IO

IO.fx {
        effect { _viewState.postValue(ViewState.Loading) }.bind()
        continueOn(dispatchers().io()) // dispatchers from Arrow
        val repositoryDto: RepositoryDto = effect { service.getRepository() }.bind()
        continueOn(Dispatchers.Default) // Dispatchers from Coroutines
        ViewState.Content(repositoryDto)
    }
4

1 回答 1

1

没有首选方式,用户可以选择使用一种或两种方式一起使用。

而 Arrow Fx 的池提供了几个Executor类似于其他功能效果库的简单池。这些使用功能方法非常有效。

另一方面,KotlinX 的调度程序目前提供了更多功能,例如EventLoop,它通过加载Main调度程序ServiceLoader 并具有测试支持。

我也在使用协程集成来运行 IO

Arrow Fx 的 IO 的 KotlinX 集成模块仅用于与结构化并发集成CoroutineScope

于 2020-05-10T11:56:16.823 回答