fix(ViewModel): Use single source of compose state
This commit is contained in:
parent
40bea14162
commit
eae30c738a
@ -263,15 +263,11 @@ class RememberStateFlowScopeImpl(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun <T> mutableComposeState(sink: MutableStateFlow<T>): MutableState<T> {
|
override fun <T> mutableComposeState(sink: MutableStateFlow<T>): MutableState<T> {
|
||||||
val state = mutableStateOf(sink.value)
|
val entry = registry.values.firstOrNull { it.sink === sink }
|
||||||
// Send back the data from a source of truth to the
|
requireNotNull(entry) {
|
||||||
// screen's storage.
|
"Provided sink must be created using mutablePersistedFlow(...)!"
|
||||||
snapshotFlow { state.value }
|
|
||||||
.onEach { text ->
|
|
||||||
sink.value = text
|
|
||||||
}
|
}
|
||||||
.launchIn(screenScope)
|
return entry.composeState.mutableState as MutableState<T>
|
||||||
return state
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun persistedState(): LeBundle {
|
override fun persistedState(): LeBundle {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user