Because if it's like this, if for instance I have ...
# coroutines
p
Because if it's like this, if for instance I have a CoroutineDispatcher injected that is the IO and the CoroutineScope tha tis the
MainScope()
and I use it like :
Copy code
@Inject constructor(
...
...
private val mainScope : CoroutineScope,
private val ioDispatcher: CoroutineDispatcher,
...
...
)
And then using it like this
Copy code
mainScope.launch{
  ...
  result withContext(ioDispatcher) {...}
  ...
}
If I do
Dispatchers.setMain(TestCoroutineDispatcher())
does it change also the
ioDispatcher
? On my test I'm doing it like this :
Copy code
private val testDispatcher = TestCoroutineDispatcher()
private val mainScope = TestCoroutineScope(testDispatcher)
And then on the
@Before
I'm using this
Dispatchers.setMain(testDispatcher)
And on every test I'm using
Copy code
mainScope.runBlockingTest{...}
or
testDispatcher.runBlockingTest{...}
Is something I could improve?
g
does it change also the 
ioDispatcher
No, there is no such mechanism for other dispatchers
👍🏽 1
private val testDispatcher = TestCoroutineDispatcher()
private val mainScope = TestCoroutineScope(testDispatcher)
It’s redundant, you can just use TestCoroutineScope()
p
Sorry Andrey, I was reading again and what you think is redundant I got it, but it is a problem with my DI? I mean I have an inject for the CoroutineScope and one for the CoroutineDispatcher so that's why on my test I create both to pass them as a parameter, is that ok?
What I mean is on my test I have to create my presenter and now I was doing this :
Copy code
private val testDispatcher = TestCoroutineDispatcher()
private val mainScope = TestCoroutineScope(testDispatcher)

...
presenter(...,mainScope,testDispatcher)
This is still redundant?
g
If your dispatcher argument is something like ioDispatcher, so it explicitly requests some dispatcher to manage IO, then it's not redundant
But most of code, which doesn't require CPU or IO related dispatchers explicitly, probably could work only with scope
p
On my presenter you mean? I'm injecting CoroutineScope as MainScope() and CoroutineDispatcher as Dispatchers.IO so, I show the progress in the main thread and then change it to IO to do api request and go back to main
g
Yep, makes sense to inject IO separately, if you need it, but not for api request
Api request should be already run on 9wn thread what kind http client do you use?
p
Still with some doubts about that check my last message please @gildor :((
g
what kind doubts?
p
I've asked another question on the bottom of the channel see please