Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert from injecting CoroutineDispatchers to CoroutineContexts #2325

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package com.alexvanyo.composelife.dispatchers

import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.test.TestDispatcher
import me.tatarka.inject.annotations.Inject
Expand All @@ -34,9 +33,9 @@ class TestComposeLifeDispatchers(
generalTestDispatcher: @GeneralTestDispatcher TestDispatcher,
cellTickerTestDispatcher: @CellTickerTestDispatcher TestDispatcher,
) : ComposeLifeDispatchers {
override val Default: CoroutineDispatcher = generalTestDispatcher
override val Main: CoroutineDispatcher = generalTestDispatcher
override val Unconfined: CoroutineDispatcher = Dispatchers.Unconfined
override val IO: CoroutineDispatcher = generalTestDispatcher
override val Default: CoroutineContext = generalTestDispatcher
override val Main: CoroutineContext = generalTestDispatcher
override val Unconfined: CoroutineContext = Dispatchers.Unconfined
override val IO: CoroutineContext = generalTestDispatcher
override val CellTicker: CoroutineContext = cellTickerTestDispatcher
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@

package com.alexvanyo.composelife.dispatchers

import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.IO
import kotlinx.coroutines.MainCoroutineDispatcher
import me.tatarka.inject.annotations.Inject
import kotlin.coroutines.CoroutineContext
import kotlin.coroutines.EmptyCoroutineContext
Expand All @@ -32,22 +29,22 @@ interface ComposeLifeDispatchers {
/**
* @see Dispatchers.Default
*/
val Default: CoroutineDispatcher
val Default: CoroutineContext

/**
* @see Dispatchers.Main
*/
val Main: CoroutineDispatcher
val Main: CoroutineContext

/**
* @see Dispatchers.Unconfined
*/
val Unconfined: CoroutineDispatcher
val Unconfined: CoroutineContext

/**
* @see Dispatchers.IO
*/
val IO: CoroutineDispatcher
val IO: CoroutineContext

/**
* The [CoroutineContext] for driving cell state ticks, in response to time delays.
Expand All @@ -61,9 +58,9 @@ interface ComposeLifeDispatchers {
@Suppress("InjectDispatcher")
@Inject
class DefaultComposeLifeDispatchers : ComposeLifeDispatchers {
override val Default: CoroutineDispatcher = Dispatchers.Default
override val Main: MainCoroutineDispatcher = Dispatchers.Main
override val Unconfined: CoroutineDispatcher = Dispatchers.Unconfined
override val IO: CoroutineDispatcher = Dispatchers.IO
override val Default: CoroutineContext = Dispatchers.Default
override val Main: CoroutineContext = Dispatchers.Main
override val Unconfined: CoroutineContext = Dispatchers.Unconfined
override val IO: CoroutineContext = Dispatchers.IO
override val CellTicker: CoroutineContext = EmptyCoroutineContext
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import coil3.disk.DiskCache
import com.alexvanyo.composelife.dispatchers.ComposeLifeDispatchers
import com.alexvanyo.composelife.filesystem.di.FileSystemModule
import com.alexvanyo.composelife.scopes.Singleton
import kotlinx.coroutines.CoroutineDispatcher
import me.tatarka.inject.annotations.Provides
import okio.FileSystem

Expand All @@ -32,6 +33,6 @@ interface ImageLoaderDiskCacheComponent : FileSystemModule {
): DiskCache = DiskCache.Builder()
.directory(FileSystem.SYSTEM_TEMPORARY_DIRECTORY / "coil3_disk_cache")
.fileSystem(fileSystem)
.cleanupDispatcher(dispatchers.IO)
.cleanupDispatcher(dispatchers.IO as CoroutineDispatcher)
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.build()
}
Loading