Last active
January 31, 2022 08:46
-
-
Save Farhandroid/f51c57613143bcc2775c0bba92dadbf3 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
@HiltViewModel | |
class HomeViewModel @Inject constructor( | |
private val getPopularMoviesUseCase: GetPopularMoviesUseCase | |
) : ViewModel() { | |
private val _movieState = mutableStateOf<Result<MovieList>>(Result.Loading()) | |
val movieState: State<Result<MovieList>> = _movieState | |
init { | |
getPopularMovies() | |
} | |
private fun getPopularMovies() { | |
viewModelScope.launch { | |
_movieState.value = getPopularMoviesUseCase() | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment