refactor(core): integrate localDbModule into DI setup and update SyncManager to use named apiClient

Added `localDbModule` to the Koin initialization list in `main.kt` for enhanced modularity. Updated `SyncManager` DI in `SyncModule.kt` to use the named `apiClient` for better dependency resolution. Improved code maintainability.
This commit is contained in:
2026-01-19 17:02:15 +01:00
parent d03b888676
commit cc4d90d23f
2 changed files with 6 additions and 4 deletions
@@ -1,12 +1,13 @@
package at.mocode.frontend.core.sync.di package at.mocode.frontend.core.sync.di
import at.mocode.frontend.core.sync.SyncManager import at.mocode.frontend.core.sync.SyncManager
import org.koin.core.qualifier.named
import org.koin.dsl.module import org.koin.dsl.module
/** /**
* Zentrales Koin-Modul für den Sync-Core. * Zentrales Koin-Modul für den Sync-Core.
*/ */
val syncModule = module { val syncModule = module {
// Provides a singleton instance of SyncManager, using the globally provided HttpClient. // Provides a singleton instance of SyncManager, using the authenticated 'apiClient'.
single { SyncManager(get()) } single { SyncManager(get(named("apiClient"))) }
} }
@@ -9,6 +9,7 @@ import at.mocode.frontend.core.sync.di.syncModule
import at.mocode.ping.feature.di.pingFeatureModule import at.mocode.ping.feature.di.pingFeatureModule
import at.mocode.frontend.core.localdb.AppDatabase import at.mocode.frontend.core.localdb.AppDatabase
import at.mocode.frontend.core.localdb.DatabaseProvider import at.mocode.frontend.core.localdb.DatabaseProvider
import at.mocode.frontend.core.localdb.localDbModule
import navigation.navigationModule import navigation.navigationModule
import kotlinx.coroutines.runBlocking import kotlinx.coroutines.runBlocking
import org.koin.core.context.loadKoinModules import org.koin.core.context.loadKoinModules
@@ -18,8 +19,8 @@ fun main() = application {
// Initialize DI (Koin) with shared modules + network module // Initialize DI (Koin) with shared modules + network module
try { try {
// Updated: Only load the consolidated pingFeatureModule from at.mocode.ping.feature.di // Updated: Only load the consolidated pingFeatureModule from at.mocode.ping.feature.di
initKoin { modules(networkModule, syncModule, pingFeatureModule, authFeatureModule, navigationModule) } initKoin { modules(networkModule, syncModule, pingFeatureModule, authFeatureModule, navigationModule, localDbModule) }
println("[DesktopApp] Koin initialized with networkModule + authFeatureModule + navigationModule + pingFeatureModule") println("[DesktopApp] Koin initialized with networkModule + authFeatureModule + navigationModule + pingFeatureModule + localDbModule")
} catch (e: Exception) { } catch (e: Exception) {
println("[DesktopApp] Koin initialization warning: ${e.message}") println("[DesktopApp] Koin initialization warning: ${e.message}")
} }