Created
May 11, 2021 11:18
-
-
Save JoseAlcerreca/4f8d69ef0e8225b4a067d5f42ee95303 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyViewModel { | |
private val _myUiState = MutableStateFlow<Result<UiState>>(Result.Loading) | |
val myUiState: StateFlow<Result<UiState>> = _myUiState | |
// Load data from a suspend fun and mutate state | |
init { | |
viewModelScope.launch { | |
val result = ... | |
_myUiState.value = result | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment