1
0
Fork 0
happy-cat/src/nativeMain/kotlin/fi/schro/di/Modules.kt

51 lines
1.3 KiB
Kotlin

/*
* Copyright (c) 2022 Florian Schrofner
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
package fi.schro.di
import fi.schro.data.ConfigurationRepository
import fi.schro.data.ConfigurationRepositoryImpl
import fi.schro.data.ElgatoLightRepository
import fi.schro.data.LightRepository
import fi.schro.ui.ApplyCommand
import fi.schro.ui.DaemonCommand
import fi.schro.ui.GetCommand
import fi.schro.ui.SetCommand
import fi.schro.util.FileUtil
import fi.schro.util.FileUtilImpl
import io.ktor.client.*
import io.ktor.client.engine.cio.*
import org.koin.dsl.module
val commandModule = module {
single{ ApplyCommand(get()) }
single{ DaemonCommand(get()) }
single{ SetCommand(get()) }
single{ GetCommand(get()) }
}
val dataModule = module {
single<LightRepository> { ElgatoLightRepository() }
single<ConfigurationRepository> { ConfigurationRepositoryImpl(get(), get()) }
}
val networkModule = module {
//HttpClient has to be recreated every time it is used
factory<HttpClient> { HttpClient(CIO)}
}
val fileModule = module {
single<FileUtil> { FileUtilImpl() }
}
val mainModule = listOf(
commandModule,
dataModule,
networkModule,
fileModule
)