Created
June 17, 2017 19:11
-
-
Save Axrorxoja/dae1ccb603a6d95b059abb478e764534 to your computer and use it in GitHub Desktop.
This file contains 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 MainRepoImpl(private val api: ApiService) : IMainRepo { | |
val TAG: String = javaClass.simpleName | |
var isFirst = false | |
var cache = Observable.empty<Message>() | |
override | |
fun loadData(): Observable<Message> { | |
if (!isFirst) { | |
cache = api.loadIp() | |
.subscribeOn(Schedulers.io()) | |
.filter { (origin) -> origin.isNotEmpty() } | |
.observeOn(AndroidSchedulers.mainThread()) | |
.doOnError { t -> Log.d(TAG, t.message) } | |
.cache() | |
isFirst = true | |
} | |
return cache | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment