Skip to content

Instantly share code, notes, and snippets.

@herisulistiyanto
Last active November 11, 2019 09:08
Show Gist options
  • Save herisulistiyanto/077e679209a6f22eb7ef67c0507ce60c to your computer and use it in GitHub Desktop.
Save herisulistiyanto/077e679209a6f22eb7ef67c0507ce60c to your computer and use it in GitHub Desktop.
class DashboardViewModel(private val movieRemoteDataSource: MovieRemoteDataSource) : ViewModel() {
private val _movieResult = MutableLiveData<ResponseResult<ResponseWrapper<MovieResponse>>>()
val movieResult: LiveData<ResponseResult<ResponseWrapper<MovieResponse>>> get() = _movieResult
fun discoverAllMovies() {
viewModelScope.launch {
val response = movieRemoteDataSource.discoverAllMovies(it)
//usually i do like this, but it will give null when we observe movieResult
_movieResult.value = response.value
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment