Skip to content

Instantly share code, notes, and snippets.

@hadilq
Created December 12, 2019 17:47
Show Gist options
  • Save hadilq/5e93c11fa55d8f840022ff5d50f6f96c to your computer and use it in GitHub Desktop.
Save hadilq/5e93c11fa55d8f840022ff5d50f6f96c to your computer and use it in GitHub Desktop.
class AlbumsViewModel : BaseViewModel {
private val networkErrorLiveData = BehaviorProcessor.create<Throwable>()
private val openAlbumDetailsLiveEvent = PublishProcessor.create<Album>()
fun albumsLiveData(): Flowable<List<Album>> = albumsLiveData.hide().observeOn(AndroidSchedulers.mainThread())
fun networkErrorLiveData(): Flowable<Throwable> =
networkErrorLiveData.hide().observeOn(AndroidSchedulers.mainThread())
fun postAlbums(albums: List<Album>) {
albumsLiveData.offer(albums)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment