Skip to content

Instantly share code, notes, and snippets.

@marcinOz
Last active June 14, 2018 10:51
Show Gist options
  • Save marcinOz/0c5f1018e66fbc603c4fe4b47e7d2379 to your computer and use it in GitHub Desktop.
Save marcinOz/0c5f1018e66fbc603c4fe4b47e7d2379 to your computer and use it in GitHub Desktop.
Kotlin ViewModel AAC
class MovieListViewModel @Inject constructor(private val dataProvider: DataProvider) : ViewModel() {
val movieDiscover = MutableLiveData<List<Movie>>()
fun fetchMovieDiscover() {
dataProvider.getMovieDiscover().subscribeBy(
onSuccess = { result -> movieDiscover.postValue(result)
},
onError = { error -> movieDiscover.postValue(null) }
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment