Update in-app update checking
This commit is contained in:
@@ -3,11 +3,11 @@ package org.koitharu.kotatsu.utils.ext
|
||||
import androidx.lifecycle.LifecycleOwner
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.liveData
|
||||
import kotlin.coroutines.CoroutineContext
|
||||
import kotlin.coroutines.EmptyCoroutineContext
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
import org.koitharu.kotatsu.utils.BufferedObserver
|
||||
import kotlin.coroutines.CoroutineContext
|
||||
import kotlin.coroutines.EmptyCoroutineContext
|
||||
|
||||
fun <T> LiveData<T>.requireValue(): T = checkNotNull(value) {
|
||||
"LiveData value is null"
|
||||
@@ -22,12 +22,12 @@ fun <T> LiveData<T>.observeWithPrevious(owner: LifecycleOwner, observer: Buffere
|
||||
}
|
||||
|
||||
fun <T> StateFlow<T>.asLiveDataDistinct(
|
||||
context: CoroutineContext = EmptyCoroutineContext
|
||||
context: CoroutineContext = EmptyCoroutineContext,
|
||||
): LiveData<T> = asLiveDataDistinct(context, value)
|
||||
|
||||
fun <T> Flow<T>.asLiveDataDistinct(
|
||||
context: CoroutineContext = EmptyCoroutineContext,
|
||||
defaultValue: T
|
||||
defaultValue: T,
|
||||
): LiveData<T> = liveData(context) {
|
||||
if (latestValue == null) {
|
||||
emit(defaultValue)
|
||||
@@ -37,4 +37,4 @@ fun <T> Flow<T>.asLiveDataDistinct(
|
||||
emit(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user