Skip to content

Commit

Permalink
Use regular Job in coroutine contexts
Browse files Browse the repository at this point in the history
  • Loading branch information
HeroBrine1st committed Apr 2, 2024
1 parent 415e597 commit ef158b6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import com.arkivanov.essenty.lifecycle.LifecycleOwner
import com.arkivanov.essenty.lifecycle.doOnDestroy
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.Job
import kotlinx.coroutines.cancel
import kotlin.coroutines.CoroutineContext

Expand All @@ -36,7 +36,7 @@ inline fun <T : Any> StackNavigator<T>.pushIndexed(crossinline create: (index: I
}

@Suppress("FunctionName")
fun LifecycleOwner.LifecycleScope(context: CoroutineContext = Dispatchers.Main.immediate + SupervisorJob()): CoroutineScope {
fun LifecycleOwner.LifecycleScope(context: CoroutineContext = Dispatchers.Main.immediate + Job()): CoroutineScope {
val coroutineScope = CoroutineScope(context)
lifecycle.doOnDestroy {
coroutineScope.cancel()
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/ru/herobrine1st/e621/util/InstanceBase.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ import androidx.annotation.CallSuper
import com.arkivanov.essenty.instancekeeper.InstanceKeeper
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.Job
import kotlinx.coroutines.cancel

abstract class InstanceBase : InstanceKeeper.Instance {
protected val lifecycleScope = CoroutineScope(SupervisorJob() + Dispatchers.Main.immediate)
protected val lifecycleScope = CoroutineScope(Job() + Dispatchers.Main.immediate)

@CallSuper
override fun onDestroy() {
Expand Down

0 comments on commit ef158b6

Please sign in to comment.