Skip to content

Instantly share code, notes, and snippets.

@Farhandroid
Last active January 31, 2022 08:46
Show Gist options
  • Save Farhandroid/f51c57613143bcc2775c0bba92dadbf3 to your computer and use it in GitHub Desktop.
Save Farhandroid/f51c57613143bcc2775c0bba92dadbf3 to your computer and use it in GitHub Desktop.
@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