Show load end/load failure toasts

This commit is contained in:
Kirill Kamakin
2022-11-04 22:13:57 +01:00
parent 714ff7d33f
commit 33bdaf9726
4 changed files with 72 additions and 1 deletions

View File

@@ -1,10 +1,12 @@
package gq.kirmanak.mealient.extensions
import androidx.fragment.app.Fragment
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.lifecycleScope
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.FlowCollector
import kotlinx.coroutines.flow.launchIn
fun <T> Fragment.collectWhenViewResumed(
flow: Flow<T>,
@@ -13,4 +15,8 @@ fun <T> Fragment.collectWhenViewResumed(
fun Fragment.launchWhenViewResumed(
block: suspend CoroutineScope.() -> Unit,
) = viewLifecycleOwner.lifecycleScope.launchWhenResumed(block)
) = viewLifecycleOwner.lifecycleScope.launchWhenResumed(block)
fun <T> Flow<T>.launchIn(lifecycleOwner: LifecycleOwner) {
launchIn(lifecycleOwner.lifecycleScope)
}