fix: Access to state register using synchronized block

This commit is contained in:
Artem Chepurnoy 2024-01-08 11:32:10 +02:00
parent eae30c738a
commit c662c8378c
No known key found for this signature in database
GPG Key ID: FAC37D0CF674043E
1 changed files with 3 additions and 1 deletions

View File

@ -263,7 +263,9 @@ class RememberStateFlowScopeImpl(
}
override fun <T> mutableComposeState(sink: MutableStateFlow<T>): MutableState<T> {
val entry = registry.values.firstOrNull { it.sink === sink }
val entry = synchronized(this) {
registry.values.firstOrNull { it.sink === sink }
}
requireNotNull(entry) {
"Provided sink must be created using mutablePersistedFlow(...)!"
}