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

47 lines
1.2 KiB
Kotlin
Raw Normal View History

2022-02-20 11:21:11 -05:00
/*
* 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/.
*/
2022-02-12 09:28:46 -05:00
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
2022-02-20 11:09:25 -05:00
import fi.schro.ui.DaemonCommand
import fi.schro.ui.GetCommand
import fi.schro.ui.SetCommand
import io.ktor.client.*
import io.ktor.client.engine.cio.*
2022-02-14 15:38:34 -05:00
import io.ktor.client.features.json.*
import org.koin.dsl.module
val commandModule = module {
2022-02-19 11:37:09 -05:00
single{ ApplyCommand(get()) }
2022-02-20 11:09:25 -05:00
single{ DaemonCommand(get()) }
2022-02-14 16:18:58 -05:00
single{ SetCommand(get()) }
single{ GetCommand(get()) }
}
val dataModule = module {
2022-02-20 11:09:25 -05:00
single<LightRepository> { ElgatoLightRepository() }
single<ConfigurationRepository> { ConfigurationRepositoryImpl(get()) }
}
val networkModule = module {
2022-02-20 11:09:25 -05:00
//HttpClient has to be recreated every time it is used
factory<HttpClient> { HttpClient(CIO){
2022-02-14 15:38:34 -05:00
install(JsonFeature)
}}
}
val mainModule = listOf(
commandModule,
dataModule,
networkModule
)