in sample/src/main/kotlin/autodispose2/sample/DisposingViewModel.kt [71:84]
fun downloadLargeImage() {
// Notify UI that we're loading network
viewRelay.accept(DownloadState.Started)
repository
.downloadProgress()
.subscribeOn(Schedulers.io())
.doOnDispose { Log.i(TAG, "Disposing subscription from the ViewModel") }
.autoDispose(this)
.subscribe(
{ progress -> viewRelay.accept(DownloadState.InProgress(progress)) },
{ error -> error.printStackTrace() },
{ viewRelay.accept(DownloadState.Completed) }
)
}