fx块内的IO调度程序与KotlinX调度程序

问题描述 投票:0回答:1

[使用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)
    }
kotlin arrow-kt
1个回答
1
投票

没有首选的方法,用户可以选择使用一种,或同时使用。

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

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

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

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

© www.soinside.com 2019 - 2024. All rights reserved.