Switch to Koin from Injekt (#1109)

replace "com.github.inorichi.injekt" with "com.github.null2264:injekt-koin"
This commit is contained in:
schroda
2024-11-09 17:32:51 +01:00
committed by GitHub
parent 654a3cc7ed
commit f5680c6d69
4 changed files with 27 additions and 33 deletions
+5 -1
View File
@@ -13,6 +13,7 @@ twelvemonkeys = "3.11.0"
graphqlkotlin = "6.8.5"
xmlserialization = "0.86.2"
ktlint = "1.3.1"
koin-bom = "4.0.0"
[libraries]
# Kotlin
@@ -69,13 +70,16 @@ exposed-migrations = "com.github.Suwayomi:exposed-migrations:3.2.0"
# Dependency Injection
kodein = "org.kodein.di:kodein-di-conf-jvm:7.20.2"
koin-bom = { module = "io.insert-koin:koin-bom", version.ref = "koin-bom" }
koin-core = { module = "io.insert-koin:koin-core" }
# tray icon
systemtray-core = "com.dorkbox:SystemTray:4.4"
systemtray-utils = "com.dorkbox:Utilities:1.46" # version locked by SystemTray
systemtray-desktop = "com.dorkbox:Desktop:1.1" # version locked by SystemTray
# dependencies of Tachiyomi extensions
injekt = "com.github.inorichi.injekt:injekt-core:65b0440"
injekt = "com.github.null2264:injekt-koin:ee267b2e27"
rxjava = "io.reactivex:rxjava:1.3.8"
jsoup = "org.jsoup:jsoup:1.18.1"
+4
View File
@@ -92,6 +92,10 @@ dependencies {
implementation(libs.cron4j)
implementation(libs.cronUtils)
// koin
implementation(project.dependencies.platform(libs.koin.bom))
implementation(libs.koin.core)
}
application {
@@ -9,16 +9,15 @@ package eu.kanade.tachiyomi
import android.app.Application
import android.content.Context
import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.InjektScope
import uy.kohesive.injekt.registry.default.DefaultRegistrar
import org.koin.core.context.startKoin
open class App : Application() {
override fun onCreate() {
super.onCreate()
Injekt = InjektScope(DefaultRegistrar())
Injekt.importModule(AppModule(this))
startKoin {
modules(createAppModule(this@App))
}
// if (BuildConfig.DEBUG) Timber.plant(Timber.DebugTree())
}
@@ -24,19 +24,12 @@ import nl.adaptivity.xmlutil.serialization.XML
import org.kodein.di.DI
import org.kodein.di.conf.global
import org.kodein.di.instance
import rx.Observable
import rx.schedulers.Schedulers
import uy.kohesive.injekt.api.InjektModule
import uy.kohesive.injekt.api.InjektRegistrar
import uy.kohesive.injekt.api.addSingleton
import uy.kohesive.injekt.api.addSingletonFactory
import uy.kohesive.injekt.api.get
import org.koin.core.module.Module
import org.koin.dsl.module
class AppModule(
val app: Application,
) : InjektModule {
override fun InjektRegistrar.registerInjectables() {
addSingleton(app)
fun createAppModule(app: Application): Module {
return module {
single { app }
// addSingletonFactory { PreferencesHelper(app) }
//
@@ -46,9 +39,9 @@ class AppModule(
//
// addSingletonFactory { CoverCache(app) }
addSingletonFactory { NetworkHelper(app) }
single { NetworkHelper(app) }
addSingletonFactory { JavaScriptEngine(app) }
single { JavaScriptEngine(app) }
// addSingletonFactory { SourceManager(app).also { get<ExtensionManager>().init(it) } }
//
@@ -60,36 +53,30 @@ class AppModule(
//
// addSingletonFactory { LibrarySyncManager(app) }
addSingletonFactory {
single {
val json by DI.global.instance<Json>()
json
}
addSingletonFactory {
single {
val xml by DI.global.instance<XML>()
xml
}
addSingletonFactory {
single {
val protobuf by DI.global.instance<ProtoBuf>()
protobuf
}
}
// Asynchronously init expensive components for a faster cold start
// Asynchronously init expensive components for a faster cold start
// rxAsync { get<PreferencesHelper>() }
rxAsync { get<NetworkHelper>() }
rxAsync {
// rxAsync {
// get<SourceManager>()
// get<DownloadManager>()
}
// }
// rxAsync { get<DatabaseHelper>() }
}
private fun rxAsync(block: () -> Unit) {
Observable.fromCallable { block() }.subscribeOn(Schedulers.computation()).subscribe()
}
}