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> {
|
||||
val state = mutableStateOf(sink.value)
|
||||
// Send back the data from a source of truth to the
|
||||
// screen's storage.
|
||||
snapshotFlow { state.value }
|
||||
.onEach { text ->
|
||||
sink.value = text
|
||||
}
|
||||
.launchIn(screenScope)
|
||||
return state
|
||||
val entry = registry.values.firstOrNull { it.sink === sink }
|
||||
requireNotNull(entry) {
|
||||
"Provided sink must be created using mutablePersistedFlow(...)!"
|
||||
}
|
||||
return entry.composeState.mutableState as MutableState<T>
|
||||
}
|
||||
|
||||
override fun persistedState(): LeBundle {
|
||||
|
|
Loading…
Reference in New Issue