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:
+3
-2
@@ -1,12 +1,13 @@
|
||||
package at.mocode.frontend.core.sync.di
|
||||
|
||||
import at.mocode.frontend.core.sync.SyncManager
|
||||
import org.koin.core.qualifier.named
|
||||
import org.koin.dsl.module
|
||||
|
||||
/**
|
||||
* Zentrales Koin-Modul für den Sync-Core.
|
||||
*/
|
||||
val syncModule = module {
|
||||
// Provides a singleton instance of SyncManager, using the globally provided HttpClient.
|
||||
single { SyncManager(get()) }
|
||||
// Provides a singleton instance of SyncManager, using the authenticated 'apiClient'.
|
||||
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.frontend.core.localdb.AppDatabase
|
||||
import at.mocode.frontend.core.localdb.DatabaseProvider
|
||||
import at.mocode.frontend.core.localdb.localDbModule
|
||||
import navigation.navigationModule
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.koin.core.context.loadKoinModules
|
||||
@@ -18,8 +19,8 @@ fun main() = application {
|
||||
// Initialize DI (Koin) with shared modules + network module
|
||||
try {
|
||||
// Updated: Only load the consolidated pingFeatureModule from at.mocode.ping.feature.di
|
||||
initKoin { modules(networkModule, syncModule, pingFeatureModule, authFeatureModule, navigationModule) }
|
||||
println("[DesktopApp] Koin initialized with networkModule + authFeatureModule + navigationModule + pingFeatureModule")
|
||||
initKoin { modules(networkModule, syncModule, pingFeatureModule, authFeatureModule, navigationModule, localDbModule) }
|
||||
println("[DesktopApp] Koin initialized with networkModule + authFeatureModule + navigationModule + pingFeatureModule + localDbModule")
|
||||
} catch (e: Exception) {
|
||||
println("[DesktopApp] Koin initialization warning: ${e.message}")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user