blakelee
08/04/2017, 12:56 AMfun refreshHoldings(convert: String) {
this.convert = convert
db.getHoldings()
.observeOn(<http://Schedulers.io|Schedulers.io>())
.map { items -> Observable.fromIterable(items).flatMap{ repo.insertCoinById(it.id, convert)} }
}
For the insert part, I have this:
fun insertCoinById(id: String, convert: String = "usd") =
api.getCoinById(id, convert)
.subscribeOn(<http://Schedulers.io|Schedulers.io>())
.map(this::convertToCoin)
.filter { it.id != "" } //id is set to "" if there is an error
.doOnNext { db.insertCoin(it) } //If there is an error I don't want to insert it.
I'm not sure how I can discard a result