mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2025-09-06 08:40:19 +00:00
potential fix of state value change in asMutableComposeState
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package dev.inmo.micro_utils.coroutines.compose
|
||||
|
||||
import androidx.compose.runtime.*
|
||||
import dev.inmo.micro_utils.coroutines.doInUI
|
||||
import dev.inmo.micro_utils.coroutines.subscribeSafelyWithoutExceptions
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
@@ -11,7 +12,7 @@ fun <T> Flow<T>.asMutableComposeState(
|
||||
scope: CoroutineScope
|
||||
): MutableState<T> {
|
||||
val state = mutableStateOf(initial)
|
||||
subscribeSafelyWithoutExceptions(scope) { state.value = it }
|
||||
subscribeSafelyWithoutExceptions(scope) { doInUI { state.value = it } }
|
||||
return state
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user