mirror of
				https://github.com/mihonapp/mihon.git
				synced 2025-10-31 14:27:57 +01:00 
			
		
		
		
	Use coroutines for async loading of modules
This commit is contained in:
		| @@ -11,8 +11,8 @@ import eu.kanade.tachiyomi.data.track.TrackManager | ||||
| import eu.kanade.tachiyomi.extension.ExtensionManager | ||||
| import eu.kanade.tachiyomi.network.NetworkHelper | ||||
| import eu.kanade.tachiyomi.source.SourceManager | ||||
| import rx.Observable | ||||
| import rx.schedulers.Schedulers | ||||
| import kotlinx.coroutines.GlobalScope | ||||
| import kotlinx.coroutines.launch | ||||
| import uy.kohesive.injekt.api.* | ||||
|  | ||||
| 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 | ||||
|  | ||||
|         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() | ||||
|     } | ||||
|  | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user