MarketDataService, private val marketDataMapper: MarketDataMapper) { fun getAllMarketData(): Flowable<Optional<List<MarketData >>> = store.getAll() fun fetchMarketData(): Completable = marketDataService.getMarketPrice() .subscribeOn(Schedulers.io()) .observeOn(Schedulers.computation()) .map(marketDataMapper) .doOnSuccess({ store.replaceAll(it) }) .toCompletable() } }