when using IO, in an `fx` block I can use `continu...
# arrow
s
when using IO, in an
fx
block I can use
continueOn
with
<http://dispatchers.io|dispatchers.io>()
but also
<http://Dispatchers.IO|Dispatchers.IO>
or I can mix is there a preferred way? is there any difference between the two? (I am also using the coroutines integration to run the IO)
Copy code
IO.fx {
            effect { _viewState.postValue(ViewState.Loading) }.bind()
            continueOn(dispatchers().io()) // dispatchers from IO
            val repositoryDto: RepositoryDto = effect { service.getRepository() }.bind()
            continueOn(Dispatchers.Default) // Dispatchers from Coroutines
            ViewState.Content(repositoryDto)
        }
s
No big difference. Arrow Fx pools are build on simple JVM pools so they have the least overhead, which works great in a functional style. You can choose
Dispatchers
for their testing support, we currently don’t have such support yet. I’d great to have in Arrow Fx too.
s
I'm following your lead and only switch the main pool in testing 😉
s
That has saved me from a nightmare of concurrency bugs. It also felt it forces me to think better about my threading model.
Btw posted a long answer on your
Fiber
question. I’m trying to find better APIs to deal with this issue, but we get little feedback so it’s hard to improve and iterate to better APIs.
s
s
👍