mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-09-10 19:43:20 +02:00
Use coroutines for async loading of modules
This commit is contained in:
parent
2be1256898
commit
e9e9e10805
@ -11,8 +11,8 @@ import eu.kanade.tachiyomi.data.track.TrackManager
|
|||||||
import eu.kanade.tachiyomi.extension.ExtensionManager
|
import eu.kanade.tachiyomi.extension.ExtensionManager
|
||||||
import eu.kanade.tachiyomi.network.NetworkHelper
|
import eu.kanade.tachiyomi.network.NetworkHelper
|
||||||
import eu.kanade.tachiyomi.source.SourceManager
|
import eu.kanade.tachiyomi.source.SourceManager
|
||||||
import rx.Observable
|
import kotlinx.coroutines.GlobalScope
|
||||||
import rx.schedulers.Schedulers
|
import kotlinx.coroutines.launch
|
||||||
import uy.kohesive.injekt.api.*
|
import uy.kohesive.injekt.api.*
|
||||||
|
|
||||||
class AppModule(val app: Application) : InjektModule {
|
class AppModule(val app: Application) : InjektModule {
|
||||||
@ -43,20 +43,16 @@ class AppModule(val app: Application) : InjektModule {
|
|||||||
|
|
||||||
// Asynchronously init expensive components for a faster cold start
|
// Asynchronously init expensive components for a faster cold start
|
||||||
|
|
||||||
rxAsync { get<PreferencesHelper>() }
|
GlobalScope.launch { get<PreferencesHelper>() }
|
||||||
|
|
||||||
rxAsync { get<NetworkHelper>() }
|
GlobalScope.launch { get<NetworkHelper>() }
|
||||||
|
|
||||||
rxAsync { get<SourceManager>() }
|
GlobalScope.launch { get<SourceManager>() }
|
||||||
|
|
||||||
rxAsync { get<DatabaseHelper>() }
|
GlobalScope.launch { get<DatabaseHelper>() }
|
||||||
|
|
||||||
rxAsync { get<DownloadManager>() }
|
GlobalScope.launch { get<DownloadManager>() }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun rxAsync(block: () -> Unit) {
|
|
||||||
Observable.fromCallable { block() }.subscribeOn(Schedulers.computation()).subscribe()
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user