From 6a570319f34dfe28437b215b217e06483390d4ab Mon Sep 17 00:00:00 2001 From: Alex Vanyo Date: Thu, 28 Sep 2023 08:31:05 -0700 Subject: [PATCH] Switch to applying Inject to class --- .../composelife/algorithm/ConfigurableGameOfLifeAlgorithm.kt | 3 ++- .../com/alexvanyo/composelife/algorithm/HashLifeAlgorithm.kt | 3 ++- .../composelife/algorithm/NaiveGameOfLifeAlgorithm.kt | 3 ++- .../com/alexvanyo/composelife/model/CellStateSerialization.kt | 3 ++- .../com/alexvanyo/composelife/appcompatsync/AppCompatSync.kt | 3 ++- .../com/alexvanyo/composelife/data/CellStateRepositoryImpl.kt | 3 ++- .../kotlin/com/alexvanyo/composelife/database/CellStateId.kt | 3 ++- .../composelife/dispatchers/TestComposeLifeDispatchers.kt | 3 ++- .../composelife/dispatchers/ComposeLifeDispatchers.kt | 3 ++- .../alexvanyo/composelife/donotkeepprocess/DoNotKeepProcess.kt | 3 ++- .../composelife/preferences/DefaultComposeLifePreferences.kt | 3 ++- .../composelife/preferences/DiskPreferencesDataStore.kt | 3 ++- 12 files changed, 24 insertions(+), 12 deletions(-) diff --git a/algorithm/src/commonMain/kotlin/com/alexvanyo/composelife/algorithm/ConfigurableGameOfLifeAlgorithm.kt b/algorithm/src/commonMain/kotlin/com/alexvanyo/composelife/algorithm/ConfigurableGameOfLifeAlgorithm.kt index b400d3dcea..03042fe25f 100644 --- a/algorithm/src/commonMain/kotlin/com/alexvanyo/composelife/algorithm/ConfigurableGameOfLifeAlgorithm.kt +++ b/algorithm/src/commonMain/kotlin/com/alexvanyo/composelife/algorithm/ConfigurableGameOfLifeAlgorithm.kt @@ -35,7 +35,8 @@ import kotlinx.coroutines.isActive import kotlinx.coroutines.selects.select import me.tatarka.inject.annotations.Inject -class ConfigurableGameOfLifeAlgorithm @Inject constructor( +@Inject +class ConfigurableGameOfLifeAlgorithm( private val preferences: ComposeLifePreferences, private val naiveGameOfLifeAlgorithm: NaiveGameOfLifeAlgorithm, private val hashLifeAlgorithm: HashLifeAlgorithm, diff --git a/algorithm/src/commonMain/kotlin/com/alexvanyo/composelife/algorithm/HashLifeAlgorithm.kt b/algorithm/src/commonMain/kotlin/com/alexvanyo/composelife/algorithm/HashLifeAlgorithm.kt index 92e1b8af16..57fca31887 100644 --- a/algorithm/src/commonMain/kotlin/com/alexvanyo/composelife/algorithm/HashLifeAlgorithm.kt +++ b/algorithm/src/commonMain/kotlin/com/alexvanyo/composelife/algorithm/HashLifeAlgorithm.kt @@ -35,7 +35,8 @@ import me.tatarka.inject.annotations.Inject import java.util.concurrent.TimeUnit @Singleton -class HashLifeAlgorithm @Inject constructor( +@Inject +class HashLifeAlgorithm( private val dispatchers: ComposeLifeDispatchers, ) : GameOfLifeAlgorithm { diff --git a/algorithm/src/commonMain/kotlin/com/alexvanyo/composelife/algorithm/NaiveGameOfLifeAlgorithm.kt b/algorithm/src/commonMain/kotlin/com/alexvanyo/composelife/algorithm/NaiveGameOfLifeAlgorithm.kt index 8fa7c082fc..abf6bd3258 100644 --- a/algorithm/src/commonMain/kotlin/com/alexvanyo/composelife/algorithm/NaiveGameOfLifeAlgorithm.kt +++ b/algorithm/src/commonMain/kotlin/com/alexvanyo/composelife/algorithm/NaiveGameOfLifeAlgorithm.kt @@ -30,7 +30,8 @@ import me.tatarka.inject.annotations.Inject * Each generation is computed in turn, and each of the possible cells that could be alive in the next generation * is checked individually. */ -class NaiveGameOfLifeAlgorithm @Inject constructor( +@Inject +class NaiveGameOfLifeAlgorithm( private val dispatchers: ComposeLifeDispatchers, ) : GameOfLifeAlgorithm { override suspend fun computeGenerationWithStep( diff --git a/algorithm/src/commonMain/kotlin/com/alexvanyo/composelife/model/CellStateSerialization.kt b/algorithm/src/commonMain/kotlin/com/alexvanyo/composelife/model/CellStateSerialization.kt index 67d23828d1..68037616e7 100644 --- a/algorithm/src/commonMain/kotlin/com/alexvanyo/composelife/model/CellStateSerialization.kt +++ b/algorithm/src/commonMain/kotlin/com/alexvanyo/composelife/model/CellStateSerialization.kt @@ -67,7 +67,8 @@ interface CellStateSerializer { ): Sequence } -class FlexibleCellStateSerializer @Inject constructor( +@Inject +class FlexibleCellStateSerializer( private val dispatchers: ComposeLifeDispatchers, ) : CellStateSerializer { override suspend fun deserializeToCellState( diff --git a/app-compat-sync/src/androidMain/kotlin/com/alexvanyo/composelife/appcompatsync/AppCompatSync.kt b/app-compat-sync/src/androidMain/kotlin/com/alexvanyo/composelife/appcompatsync/AppCompatSync.kt index 82f8b7037e..d9d709e6e6 100644 --- a/app-compat-sync/src/androidMain/kotlin/com/alexvanyo/composelife/appcompatsync/AppCompatSync.kt +++ b/app-compat-sync/src/androidMain/kotlin/com/alexvanyo/composelife/appcompatsync/AppCompatSync.kt @@ -30,7 +30,8 @@ import kotlinx.coroutines.flow.collect import kotlinx.coroutines.flow.onEach import me.tatarka.inject.annotations.Inject -class AppCompatSync @Inject constructor( +@Inject +class AppCompatSync( private val composeLifePreferences: ComposeLifePreferences, context: ApplicationContext, ) : Updatable { diff --git a/data/src/commonMain/kotlin/com/alexvanyo/composelife/data/CellStateRepositoryImpl.kt b/data/src/commonMain/kotlin/com/alexvanyo/composelife/data/CellStateRepositoryImpl.kt index e5c060004a..808441c5b9 100644 --- a/data/src/commonMain/kotlin/com/alexvanyo/composelife/data/CellStateRepositoryImpl.kt +++ b/data/src/commonMain/kotlin/com/alexvanyo/composelife/data/CellStateRepositoryImpl.kt @@ -28,7 +28,8 @@ import com.alexvanyo.composelife.model.fromFileExtension import kotlinx.coroutines.withContext import me.tatarka.inject.annotations.Inject -class CellStateRepositoryImpl @Inject constructor( +@Inject +class CellStateRepositoryImpl( private val flexibleCellStateSerializer: FlexibleCellStateSerializer, private val cellStateQueries: CellStateQueries, private val dispatchers: ComposeLifeDispatchers, diff --git a/database/src/commonMain/kotlin/com/alexvanyo/composelife/database/CellStateId.kt b/database/src/commonMain/kotlin/com/alexvanyo/composelife/database/CellStateId.kt index f21b4b5327..b8a8d08df4 100644 --- a/database/src/commonMain/kotlin/com/alexvanyo/composelife/database/CellStateId.kt +++ b/database/src/commonMain/kotlin/com/alexvanyo/composelife/database/CellStateId.kt @@ -22,7 +22,8 @@ import me.tatarka.inject.annotations.Inject @JvmInline value class CellStateId(val value: Long) -class CellStateIdAdapter @Inject constructor() : ColumnAdapter { +@Inject +class CellStateIdAdapter : ColumnAdapter { override fun decode(databaseValue: Long): CellStateId = CellStateId(databaseValue) override fun encode(value: CellStateId): Long = value.value diff --git a/dispatchers-test/src/commonMain/kotlin/com/alexvanyo/composelife/dispatchers/TestComposeLifeDispatchers.kt b/dispatchers-test/src/commonMain/kotlin/com/alexvanyo/composelife/dispatchers/TestComposeLifeDispatchers.kt index 3efba2e9b8..f57160c24a 100644 --- a/dispatchers-test/src/commonMain/kotlin/com/alexvanyo/composelife/dispatchers/TestComposeLifeDispatchers.kt +++ b/dispatchers-test/src/commonMain/kotlin/com/alexvanyo/composelife/dispatchers/TestComposeLifeDispatchers.kt @@ -28,7 +28,8 @@ import me.tatarka.inject.annotations.Inject * [Unconfined] delegates to the default implementations, due to their custom behavior. */ @Suppress("InjectDispatcher") -class TestComposeLifeDispatchers @Inject constructor( +@Inject +class TestComposeLifeDispatchers( testDispatcher: TestDispatcher, ) : ComposeLifeDispatchers { override val Default: CoroutineDispatcher = testDispatcher diff --git a/dispatchers/src/commonMain/kotlin/com/alexvanyo/composelife/dispatchers/ComposeLifeDispatchers.kt b/dispatchers/src/commonMain/kotlin/com/alexvanyo/composelife/dispatchers/ComposeLifeDispatchers.kt index accf56af3d..260da02095 100644 --- a/dispatchers/src/commonMain/kotlin/com/alexvanyo/composelife/dispatchers/ComposeLifeDispatchers.kt +++ b/dispatchers/src/commonMain/kotlin/com/alexvanyo/composelife/dispatchers/ComposeLifeDispatchers.kt @@ -51,7 +51,8 @@ interface ComposeLifeDispatchers { * The default implementation of [ComposeLifeDispatchers], which just delegates to the normal [Dispatchers] versions. */ @Suppress("InjectDispatcher") -class DefaultComposeLifeDispatchers @Inject constructor() : ComposeLifeDispatchers { +@Inject +class DefaultComposeLifeDispatchers : ComposeLifeDispatchers { override val Default: CoroutineDispatcher = Dispatchers.Default override val Main: MainCoroutineDispatcher = Dispatchers.Main override val Unconfined: CoroutineDispatcher = Dispatchers.Unconfined diff --git a/do-not-keep-process/src/androidMain/kotlin/com/alexvanyo/composelife/donotkeepprocess/DoNotKeepProcess.kt b/do-not-keep-process/src/androidMain/kotlin/com/alexvanyo/composelife/donotkeepprocess/DoNotKeepProcess.kt index b7b4e156d8..7f424d3b06 100644 --- a/do-not-keep-process/src/androidMain/kotlin/com/alexvanyo/composelife/donotkeepprocess/DoNotKeepProcess.kt +++ b/do-not-keep-process/src/androidMain/kotlin/com/alexvanyo/composelife/donotkeepprocess/DoNotKeepProcess.kt @@ -28,7 +28,8 @@ import kotlinx.coroutines.flow.collectLatest import me.tatarka.inject.annotations.Inject import kotlin.system.exitProcess -class DoNotKeepProcess @Inject constructor( +@Inject +class DoNotKeepProcess( private val lifecycleOwner: ProcessLifecycleOwner, private val composeLifePreferences: ComposeLifePreferences, ) : Updatable { diff --git a/preferences/src/commonMain/kotlin/com/alexvanyo/composelife/preferences/DefaultComposeLifePreferences.kt b/preferences/src/commonMain/kotlin/com/alexvanyo/composelife/preferences/DefaultComposeLifePreferences.kt index ea9758ab85..3205a2446f 100644 --- a/preferences/src/commonMain/kotlin/com/alexvanyo/composelife/preferences/DefaultComposeLifePreferences.kt +++ b/preferences/src/commonMain/kotlin/com/alexvanyo/composelife/preferences/DefaultComposeLifePreferences.kt @@ -37,7 +37,8 @@ import me.tatarka.inject.annotations.Inject @Suppress("TooManyFunctions") @Singleton -class DefaultComposeLifePreferences @Inject constructor( +@Inject +class DefaultComposeLifePreferences( private val dataStore: PreferencesDataStore, ) : ComposeLifePreferences { diff --git a/preferences/src/commonMain/kotlin/com/alexvanyo/composelife/preferences/DiskPreferencesDataStore.kt b/preferences/src/commonMain/kotlin/com/alexvanyo/composelife/preferences/DiskPreferencesDataStore.kt index 4043f8dd21..daa9bb3a8e 100644 --- a/preferences/src/commonMain/kotlin/com/alexvanyo/composelife/preferences/DiskPreferencesDataStore.kt +++ b/preferences/src/commonMain/kotlin/com/alexvanyo/composelife/preferences/DiskPreferencesDataStore.kt @@ -36,7 +36,8 @@ typealias PreferencesProtoPath = Path typealias PreferencesCoroutineScope = CoroutineScope @Singleton -class DiskPreferencesDataStore @Inject constructor( +@Inject +class DiskPreferencesDataStore( fileSystem: FileSystem, path: PreferencesProtoPath, scope: PreferencesCoroutineScope,