mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2024-12-18 06:40:07 +00:00
potential fix of state value change in asMutableComposeState
This commit is contained in:
parent
8a6b4bb49e
commit
6ebc5aa0c2
@ -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
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user