Use Wholphin-specific dispatchers (#1583)
## Description Switches all usages of `kotlinx.coroutines.Dispatchers` to `WholphinDispatchers`. `WholphinDispatchers` provides an easier and more reliable mechanism to use a test dispatcher in unit tests. For regular app usage, `WholphinDispatchers` just delegates to `Dispatchers`. There are no user facing changes ### Related issues None ### Testing Basic emulator testing & unit tests ## Screenshots N/A ## AI or LLM usage None
This commit is contained in:
parent
ddbec0da73
commit
e17ae3eb8a
68 changed files with 252 additions and 226 deletions
|
|
@ -0,0 +1,21 @@
|
|||
package com.github.damontecres.wholphin.util
|
||||
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.test.TestDispatcher
|
||||
import kotlinx.coroutines.test.resetMain
|
||||
import kotlinx.coroutines.test.setMain
|
||||
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
fun WholphinDispatchers.configure(testDispatcher: TestDispatcher) {
|
||||
Dispatchers.setMain(testDispatcher)
|
||||
IO = testDispatcher
|
||||
Default = testDispatcher
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
fun WholphinDispatchers.reset() {
|
||||
Dispatchers.resetMain()
|
||||
IO = Dispatchers.IO
|
||||
Default = Dispatchers.Default
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue