Use coroutines for async loading of modules
This commit is contained in:
parent
ed8e549ecb
commit
9588a582ce
@ -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