Skip to content

Commit

Permalink
Switch to applying Inject to class
Browse files Browse the repository at this point in the history
  • Loading branch information
alexvanyo committed Sep 28, 2023
1 parent 7d53300 commit 6a57031
Show file tree
Hide file tree
Showing 12 changed files with 24 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ interface CellStateSerializer {
): Sequence<String>
}

class FlexibleCellStateSerializer @Inject constructor(
@Inject
class FlexibleCellStateSerializer(
private val dispatchers: ComposeLifeDispatchers,
) : CellStateSerializer {
override suspend fun deserializeToCellState(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ import me.tatarka.inject.annotations.Inject
@JvmInline
value class CellStateId(val value: Long)

class CellStateIdAdapter @Inject constructor() : ColumnAdapter<CellStateId, Long> {
@Inject
class CellStateIdAdapter : ColumnAdapter<CellStateId, Long> {
override fun decode(databaseValue: Long): CellStateId = CellStateId(databaseValue)

override fun encode(value: CellStateId): Long = value.value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ typealias PreferencesProtoPath = Path
typealias PreferencesCoroutineScope = CoroutineScope

@Singleton
class DiskPreferencesDataStore @Inject constructor(
@Inject
class DiskPreferencesDataStore(
fileSystem: FileSystem,
path: PreferencesProtoPath,
scope: PreferencesCoroutineScope,
Expand Down

0 comments on commit 6a57031

Please sign in to comment.