pers
09/10/2023, 1:16 PMviewModelScope.launch {
_uiState.update(newState)
}
#B
_uiState.update(newState)
#C
_uiState.value = newState
Neon
09/10/2023, 1:22 PMtryEmit
, but I personally prefer 'C' variantNeon
09/10/2023, 1:22 PMxoangon
09/10/2023, 2:45 PMsynchronized
to resolve concurrent state updates. Take a look at the source code for *`MutableStateFlow<T>.update` here*
You could end up with race conditions when using #C
There’s no need for a coroutine to update the state, option #A introduces unnecessary overheaduli
09/25/2023, 2:46 PM_uiState.update { previousState -> newState }
uli
09/25/2023, 2:48 PM