Created
January 20, 2019 10:03
-
-
Save IhwanID/25ba9ea143e47c164d9e4030d9ea4ee9 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
| package id.ihwan.aac.viewmodel | |
| import android.app.Application | |
| import androidx.lifecycle.AndroidViewModel | |
| import androidx.lifecycle.MutableLiveData | |
| import id.ihwan.aac.model.MovieResponse | |
| import id.ihwan.aac.network.MainRepository | |
| class MainViewModel(application: Application): AndroidViewModel(application) { | |
| private val repository = MainRepository() | |
| var movies : MutableLiveData<MovieResponse> = MutableLiveData() | |
| var error: MutableLiveData<Throwable> = MutableLiveData() | |
| fun getMovie(){ | |
| repository.requestMovie({ | |
| movies.postValue(it) | |
| },{ | |
| error.postValue(it) | |
| }) | |
| } | |
| override fun onCleared() { | |
| super.onCleared() | |
| repository.onDestroy() | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment