Transitioning to Unified State Management: Refactoring a Daynote ViewModel and Screen | by Murat Gunay | Dec, 2024
class ViewDaynoteViewModel : ViewModel() {private val _uiState = MutableStateFlow<ViewDaynoteUiState>(ViewDaynoteUiState.Loading)val uiState: StateFlow<ViewDaynoteUiState> = _uiState var commentText = MutableStateFlow(“”) fun loadDaynote(daynoteId: String) {viewModelScope.launch {_uiState.value = ViewDaynoteUiState.Loadingval result = daynoteRepository.getDaynoteById(daynoteId).flatMap { daynote ->userRepository.getUserPreviewById(daynote.userId).map …
Transitioning to Unified State Management: Refactoring a Daynote ViewModel and Screen | by Murat Gunay | Dec, 2024 Read More