ursus
05/31/2019, 4:37 PMDownloadManager {
private var activeDownloadObservable: Observable<Event>? = null
fun downloadSomething(params) : Observable<Event> {
if (activeDownloadObservable == null) {
activeDownloadObservable = apiActuallyDownloadAndWriteObservable(params)
.publish()
.autoConnect(1)
.doFinally {
activeDownloadObservable = null
}
}
return activeDownloadObservable!!
}
fun getActiveDownload() = activeDownloadObservable
}