Skip to content

Commit

Permalink
Add missing scopes. Forgot these during the migration.
Browse files Browse the repository at this point in the history
  • Loading branch information
thomaskioko committed Dec 7, 2024
1 parent fd5617b commit c36a03d
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ import kotlinx.coroutines.Dispatchers
import me.tatarka.inject.annotations.Provides
import software.amazon.lastmile.kotlin.inject.anvil.AppScope
import software.amazon.lastmile.kotlin.inject.anvil.ContributesTo
import software.amazon.lastmile.kotlin.inject.anvil.SingleIn

@ContributesTo(AppScope::class)
interface BaseComponent {

@Provides
@SingleIn(AppScope::class)
fun provideCoroutineDispatchers(): AppCoroutineDispatchers =
AppCoroutineDispatchers(
io = Dispatchers.Default,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ import com.thomaskioko.tvmaniac.core.logger.KermitLogger
import me.tatarka.inject.annotations.Provides
import software.amazon.lastmile.kotlin.inject.anvil.AppScope
import software.amazon.lastmile.kotlin.inject.anvil.ContributesTo
import software.amazon.lastmile.kotlin.inject.anvil.SingleIn

@ContributesTo(AppScope::class)
interface LoggingComponent {

@Provides
@SingleIn(AppScope::class)
fun provideKermitLogger(
configs: Configs,
): KermitLogger = KermitLogger(configs.isDebug)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ import com.thomaskioko.tvmaniac.util.YamlResourceReader
import me.tatarka.inject.annotations.Provides
import software.amazon.lastmile.kotlin.inject.anvil.AppScope
import software.amazon.lastmile.kotlin.inject.anvil.ContributesTo
import software.amazon.lastmile.kotlin.inject.anvil.SingleIn

@ContributesTo(AppScope::class)
interface UtilPlatformComponent {

@Provides
@SingleIn(AppScope::class)
fun provideConfigs(resourceReader: YamlResourceReader): Configs =
resourceReader.readAndDecodeResource("config.yaml", Configs.serializer())
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ import com.thomaskioko.tvmaniac.util.YamlResourceReader
import me.tatarka.inject.annotations.Provides
import software.amazon.lastmile.kotlin.inject.anvil.AppScope
import software.amazon.lastmile.kotlin.inject.anvil.ContributesTo
import software.amazon.lastmile.kotlin.inject.anvil.SingleIn

@ContributesTo(AppScope::class)
interface UtilPlatformComponent {

@Provides
@SingleIn(AppScope::class)
fun provideConfigs(resourceReader: YamlResourceReader): Configs =
resourceReader.readAndDecodeResource("config.yaml", Configs.serializer())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ import com.thomaskioko.tvmaniac.core.db.TvManiacDatabase
import me.tatarka.inject.annotations.Provides
import software.amazon.lastmile.kotlin.inject.anvil.AppScope
import software.amazon.lastmile.kotlin.inject.anvil.ContributesTo
import software.amazon.lastmile.kotlin.inject.anvil.SingleIn

@ContributesTo(AppScope::class)
interface DatabasePlatformComponent {

@Provides
@SingleIn(AppScope::class)
fun provideSqlDriver(application: Application): SqlDriver =
AndroidSqliteDriver(
schema = TvManiacDatabase.Schema,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ import com.thomaskioko.tvmaniac.core.db.TvManiacDatabase
import me.tatarka.inject.annotations.Provides
import software.amazon.lastmile.kotlin.inject.anvil.AppScope
import software.amazon.lastmile.kotlin.inject.anvil.ContributesTo
import software.amazon.lastmile.kotlin.inject.anvil.SingleIn

@ContributesTo(AppScope::class)
interface DatabasePlatformComponent {

@Provides
@SingleIn(AppScope::class)
fun provideSqlDriver(): SqlDriver = NativeSqliteDriver(TvManiacDatabase.Schema, "tvShows.db")
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ import com.thomaskioko.tvmaniac.core.base.model.AppCoroutineScope
import me.tatarka.inject.annotations.Provides
import software.amazon.lastmile.kotlin.inject.anvil.AppScope
import software.amazon.lastmile.kotlin.inject.anvil.ContributesTo
import software.amazon.lastmile.kotlin.inject.anvil.SingleIn

@ContributesTo(AppScope::class)
interface DataStorePlatformComponent {

@Provides
@SingleIn(AppScope::class)
fun provideDataStore(context: Application, scope: AppCoroutineScope): DataStore<Preferences> =
createDataStore(
coroutineScope = scope.io,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import software.amazon.lastmile.kotlin.inject.anvil.SingleIn
interface DataStorePlatformComponent {

@Provides
@SingleIn(AppScope::class)
fun provideDataStore(dispatchers: AppCoroutineScope): DataStore<Preferences> =
createDataStore(
coroutineScope = dispatchers.io,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ import io.ktor.client.engine.okhttp.OkHttp
import me.tatarka.inject.annotations.Provides
import software.amazon.lastmile.kotlin.inject.anvil.AppScope
import software.amazon.lastmile.kotlin.inject.anvil.ContributesTo
import software.amazon.lastmile.kotlin.inject.anvil.SingleIn

@ContributesTo(AppScope::class)
interface TmdbPlatformComponent {

@Provides
@SingleIn(AppScope::class)
fun provideTmdbHttpClientEngine(): TmdbHttpClientEngine = OkHttp.create()
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import kotlinx.serialization.json.Json
import me.tatarka.inject.annotations.Provides
import software.amazon.lastmile.kotlin.inject.anvil.AppScope
import software.amazon.lastmile.kotlin.inject.anvil.ContributesTo
import software.amazon.lastmile.kotlin.inject.anvil.SingleIn

typealias TmdbHttpClient = HttpClient

Expand All @@ -22,6 +23,7 @@ typealias TmdbJson = Json
interface TmdbComponent {

@Provides
@SingleIn(AppScope::class)
fun provideTmdbJson(): TmdbJson = Json {
isLenient = true
ignoreUnknownKeys = true
Expand All @@ -30,6 +32,7 @@ interface TmdbComponent {
}

@Provides
@SingleIn(AppScope::class)
fun provideTmdbHttpClient(
configs: Configs,
json: TmdbJson,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ import io.ktor.client.engine.darwin.Darwin
import me.tatarka.inject.annotations.Provides
import software.amazon.lastmile.kotlin.inject.anvil.AppScope
import software.amazon.lastmile.kotlin.inject.anvil.ContributesTo
import software.amazon.lastmile.kotlin.inject.anvil.SingleIn

@ContributesTo(AppScope::class)
interface TmdbPlatformComponent {

@Provides
@SingleIn(AppScope::class)
fun provideTmdbHttpClientEngine(): TmdbHttpClientEngine = Darwin.create()
}

0 comments on commit c36a03d

Please sign in to comment.