AuroraApp: Switch from GlobalScope to MainScope

Use MainScope instead of GlobalScope managed in the application class

Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
This commit is contained in:
Aayush Gupta
2024-05-02 12:22:06 +05:30
parent e142e4f00d
commit a75838a57d
8 changed files with 29 additions and 24 deletions

View File

@@ -1,21 +1,19 @@
package com.aurora.extensions
import android.content.BroadcastReceiver
import com.aurora.store.AuroraApp
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.DelicateCoroutinesApi
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.cancel
import kotlinx.coroutines.launch
import kotlin.coroutines.CoroutineContext
import kotlin.coroutines.EmptyCoroutineContext
@OptIn(DelicateCoroutinesApi::class)
fun BroadcastReceiver.goAsync(
context: CoroutineContext = EmptyCoroutineContext,
block: suspend CoroutineScope.() -> Unit
) {
val pendingResult = goAsync()
GlobalScope.launch(context) {
AuroraApp.scope.launch(context) {
try {
block()
} finally {