Last active
May 17, 2021 14:18
-
-
Save JoseAlcerreca/b60c6ee56267d3d32ede34fe313077a0 to your computer and use it in GitHub Desktop.
This file contains 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
val result = userId.transformLatest { newUserId -> | |
emit(Result.LoadingData) | |
emit(repository.fetchItem(newUserId)) | |
}.stateIn( | |
scope = viewModelScope, | |
started = WhileSubscribed(5000), | |
initialValue = Result.LoadingUser // Note the different Loading states | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment