Skip to content

Commit

Permalink
move viewCoroutineScope to LifecycleExtensions.kt
Browse files Browse the repository at this point in the history
  • Loading branch information
FunkyMuse committed Dec 20, 2021
1 parent 220ac5c commit 3b4c4f3
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import androidx.core.view.isVisible
import androidx.fragment.app.Fragment
import androidx.fragment.app.viewModels
import com.crazylegend.common.ifTrue
import com.crazylegend.fragment.viewCoroutineScope
import com.crazylegend.internetdetector.InternetDetector
import com.crazylegend.lifecycle.repeatingJobOnStarted
import com.crazylegend.lifecycle.viewCoroutineScope
import com.crazylegend.retrofit.apiresult.*
import com.crazylegend.retrofit.throwables.isNoConnectionException
import com.crazylegend.retrofit.viewstate.*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -670,8 +670,6 @@ fun Fragment.hasPipPermission(): Boolean {
}
}

val Fragment.viewCoroutineScope get() = viewLifecycleOwner.lifecycle.coroutineScope

inline fun Fragment.onViewDestroyed(crossinline action: () -> Unit) {
observeLifecycleOwnerThroughLifecycleCreation {
lifecycle.addObserver(object : DefaultLifecycleObserver {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleEventObserver
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.LifecycleRegistry
import androidx.lifecycle.coroutineScope
import androidx.lifecycle.lifecycleScope
import androidx.lifecycle.repeatOnLifecycle
import kotlinx.coroutines.CoroutineScope
Expand Down Expand Up @@ -76,3 +77,5 @@ fun Lifecycle.doOnEvent(which: Lifecycle.Event, block: () -> Unit) {

addObserver(observer)
}

val Fragment.viewCoroutineScope get() = viewLifecycleOwner.lifecycle.coroutineScope

0 comments on commit 3b4c4f3

Please sign in to comment.