mirror of
https://github.com/mihonapp/mihon.git
synced 2025-11-13 04:28:55 +01:00
Set preference visibility immediately (fixes #2965)
This commit is contained in:
@@ -6,6 +6,8 @@ import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.onStart
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
fun launchUI(block: suspend CoroutineScope.() -> Unit): Job =
|
||||
@@ -17,3 +19,10 @@ fun launchIO(block: suspend CoroutineScope.() -> Unit): Job =
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
fun launchNow(block: suspend CoroutineScope.() -> Unit): Job =
|
||||
GlobalScope.launch(Dispatchers.Main, CoroutineStart.UNDISPATCHED, block)
|
||||
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
fun <T> Flow<T>.startWithCurrentValue(block: () -> T?): Flow<T> {
|
||||
return onStart {
|
||||
block()?.let { emit(it) }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user