mirror of
				https://github.com/mihonapp/mihon.git
				synced 2025-10-31 14:27:57 +01:00 
			
		
		
		
	Add DelicateCoroutinesApi to GlobalScope extension functions (#7848)
This commit is contained in:
		| @@ -2,18 +2,43 @@ package eu.kanade.tachiyomi.util.lang | ||||
|  | ||||
| import kotlinx.coroutines.CoroutineScope | ||||
| import kotlinx.coroutines.CoroutineStart | ||||
| import kotlinx.coroutines.DelicateCoroutinesApi | ||||
| import kotlinx.coroutines.Dispatchers | ||||
| import kotlinx.coroutines.GlobalScope | ||||
| import kotlinx.coroutines.Job | ||||
| import kotlinx.coroutines.launch | ||||
| import kotlinx.coroutines.withContext | ||||
|  | ||||
| /** | ||||
|  * Think twice before using this. This is a delicate API. It is easy to accidentally create resource or memory leaks when GlobalScope is used. | ||||
|  * | ||||
|  * **Possible replacements** | ||||
|  * - suspend function | ||||
|  * - custom scope like view or presenter scope | ||||
|  */ | ||||
| @DelicateCoroutinesApi | ||||
| fun launchUI(block: suspend CoroutineScope.() -> Unit): Job = | ||||
|     GlobalScope.launch(Dispatchers.Main, CoroutineStart.DEFAULT, block) | ||||
|  | ||||
| /** | ||||
|  * Think twice before using this. This is a delicate API. It is easy to accidentally create resource or memory leaks when GlobalScope is used. | ||||
|  * | ||||
|  * **Possible replacements** | ||||
|  * - suspend function | ||||
|  * - custom scope like view or presenter scope | ||||
|  */ | ||||
| @DelicateCoroutinesApi | ||||
| fun launchIO(block: suspend CoroutineScope.() -> Unit): Job = | ||||
|     GlobalScope.launch(Dispatchers.IO, CoroutineStart.DEFAULT, block) | ||||
|  | ||||
| /** | ||||
|  * Think twice before using this. This is a delicate API. It is easy to accidentally create resource or memory leaks when GlobalScope is used. | ||||
|  * | ||||
|  * **Possible replacements** | ||||
|  * - suspend function | ||||
|  * - custom scope like view or presenter scope | ||||
|  */ | ||||
| @DelicateCoroutinesApi | ||||
| fun launchNow(block: suspend CoroutineScope.() -> Unit): Job = | ||||
|     GlobalScope.launch(Dispatchers.Main, CoroutineStart.UNDISPATCHED, block) | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user