Created
June 14, 2018 10:54
-
-
Save marcinOz/9a88d99bfc43563c99285234de47d458 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
class MovieListViewModel @Inject constructor(private val dataProvider: DataProvider) : ViewModel() { | |
val movieDiscover = MutableLiveData<ResourceState>() | |
fun fetchMovieDiscover() { | |
movieDiscover.postValue(LoadingState()) | |
dataProvider.getMovieDiscover().subscribeBy( | |
onSuccess = { result -> | |
if (result.isEmpty()) movieDiscover.postValue(EmptyState()) | |
else movieDiscover.postValue(PopulatedState(result)) | |
}, | |
onError = { error -> movieDiscover.postValue(ErrorState(error.message)) } | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment