Skip to content

Commit

Permalink
Create new module called ::core:di
Browse files Browse the repository at this point in the history
  • Loading branch information
ksharma-xyz committed Jan 3, 2025
1 parent 7cd6306 commit 774cbe3
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 14 deletions.
7 changes: 4 additions & 3 deletions composeApp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,15 @@ kotlin {

commonMain.dependencies {
implementation(projects.core.analytics)
implementation(projects.taj)
implementation(projects.sandook)
implementation(projects.core.appInfo)
implementation(projects.core.di)
implementation(projects.core.log)
implementation(projects.core.remoteConfig)
implementation(projects.feature.tripPlanner.network)
implementation(projects.feature.tripPlanner.ui)
implementation(projects.feature.tripPlanner.state)
implementation(projects.feature.tripPlanner.ui)
implementation(projects.sandook)
implementation(projects.taj)

implementation(libs.navigation.compose)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import org.koin.dsl.koinConfiguration
import org.koin.dsl.module
import xyz.ksharma.krail.core.analytics.di.analyticsModule
import xyz.ksharma.krail.core.appinfo.di.appInfoModule
import xyz.ksharma.krail.core.di.coroutineDispatchersModule
import xyz.ksharma.krail.core.remote_config.di.remoteConfigModule
import xyz.ksharma.krail.sandook.di.sandookModule
import xyz.ksharma.krail.splash.SplashViewModel
Expand All @@ -23,6 +24,7 @@ val koinConfig = koinConfiguration {
appInfoModule,
analyticsModule,
remoteConfigModule,
coroutineDispatchersModule,
)
}

Expand Down
43 changes: 43 additions & 0 deletions core/di/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
plugins {
alias(libs.plugins.krail.android.library)
alias(libs.plugins.krail.kotlin.multiplatform)
alias(libs.plugins.krail.compose.multiplatform)
alias(libs.plugins.compose.compiler)
}

android {
namespace = "xyz.ksharma.krail.core.di"
}

kotlin {
applyDefaultHierarchyTemplate()

androidTarget()

iosArm64()
iosSimulatorArm64()

java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(JavaVersion.VERSION_17.majorVersion))
}
}

sourceSets {
androidMain {
dependencies {
api(libs.di.koinAndroid)
}
}

commonMain {
dependencies {
implementation(compose.runtime)
api(libs.di.koinComposeViewmodel)
}
}

iosMain.dependencies {
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package xyz.ksharma.krail.core.analytics.di
package xyz.ksharma.krail.core.di

import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.CoroutineScope
Expand All @@ -9,9 +9,9 @@ import org.koin.core.component.KoinComponent
import org.koin.core.qualifier.named
import org.koin.dsl.module
import org.koin.core.component.inject
import xyz.ksharma.krail.core.analytics.di.DispatchersComponent.Companion.DefaultDispatcher
import xyz.ksharma.krail.core.analytics.di.DispatchersComponent.Companion.IODispatcher
import xyz.ksharma.krail.core.analytics.di.DispatchersComponent.Companion.MainDispatcher
import xyz.ksharma.krail.core.di.DispatchersComponent.Companion.DefaultDispatcher
import xyz.ksharma.krail.core.di.DispatchersComponent.Companion.IODispatcher
import xyz.ksharma.krail.core.di.DispatchersComponent.Companion.MainDispatcher

open class DispatchersComponent : KoinComponent {

Expand All @@ -28,7 +28,7 @@ open class DispatchersComponent : KoinComponent {
}
}

val coroutineModule = module {
val coroutineDispatchersModule = module {

single(named(DefaultDispatcher)) {
Dispatchers.Default
Expand All @@ -43,6 +43,6 @@ val coroutineModule = module {
}

single {
CoroutineScope(SupervisorJob() + Dispatchers.Default)
CoroutineScope(context = SupervisorJob() + Dispatchers.Default)
}
}
3 changes: 2 additions & 1 deletion core/remote-config/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ kotlin {

commonMain {
dependencies {
implementation(projects.core.log)
implementation(projects.core.appInfo)
implementation(projects.core.di)
implementation(projects.core.log)

implementation(libs.kotlinx.serialization.json)
implementation(compose.runtime)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,9 @@ import dev.gitlive.firebase.remoteconfig.remoteConfig
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.launch
import org.koin.core.component.inject
import org.koin.core.qualifier.named
import xyz.ksharma.krail.core.analytics.di.DispatchersComponent
import xyz.ksharma.krail.core.di.DispatchersComponent
import xyz.ksharma.krail.core.appinfo.AppInfoProvider
import kotlin.time.Duration.Companion.minutes
import kotlin.time.Duration.Companion.seconds

internal class RealRemoteConfig(
private val appInfoProvider: AppInfoProvider,
Expand Down
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ include(":taj") // Design System
include(":core:analytics")
include(":core:app-info")
include(":core:date-time")
include(":core:di")
include(":core:log")
include(":core:remote-config")
include(":feature:trip-planner:ui")
Expand Down

0 comments on commit 774cbe3

Please sign in to comment.