From 4668f61d45bf4795eedd11d86121da9475758757 Mon Sep 17 00:00:00 2001 From: Andrej Jurkin Date: Thu, 28 Sep 2017 21:29:26 +0200 Subject: [PATCH] Change refresh interval to timer in order to subscribe without a delay --- Nova/repository/DataRepository.swift | 5 +++-- Nova/view/tickerlist/TickerListViewController.swift | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Nova/repository/DataRepository.swift b/Nova/repository/DataRepository.swift index 318b54f..6483907 100644 --- a/Nova/repository/DataRepository.swift +++ b/Nova/repository/DataRepository.swift @@ -84,6 +84,7 @@ class DataRepository { } /// Get all tickers from remote repository + /// Cache response into Realm /// /// - returns: /// An empty observable to notify the UI when finished @@ -134,7 +135,7 @@ class DataRepository { self.tickerUpdateSubscription?.dispose() self.tickerUpdateSubscription = - Observable.interval(RxTimeInterval(refreshInterval), scheduler: Schedulers.background) + Observable.timer(0, period: RxTimeInterval(refreshInterval), scheduler: Schedulers.background) // Query Cryptonator api for an update .flatMap { _ -> Observable<[String: [String: Double]]> in print("Pinned tickers updated") @@ -165,7 +166,7 @@ class DataRepository { self.globalRefreshSubscription?.dispose() self.globalRefreshSubscription = - Observable.interval(RxTimeInterval(refreshIntervalMinutes * 60), scheduler: Schedulers.background) + Observable.timer(0, period: RxTimeInterval(refreshIntervalMinutes * 60), scheduler: Schedulers.background) // Query Cryptonator api for an update .flatMap { _ -> Observable<[Ticker]> in diff --git a/Nova/view/tickerlist/TickerListViewController.swift b/Nova/view/tickerlist/TickerListViewController.swift index b824976..564470c 100644 --- a/Nova/view/tickerlist/TickerListViewController.swift +++ b/Nova/view/tickerlist/TickerListViewController.swift @@ -94,6 +94,8 @@ class TickerListViewController: NSViewController, NSTableViewDelegate, NSTableVi @IBAction func onRefreshButtonClick(_ sender: Any) { self.viewModel.refresh() + + AppDelegate.shared().menuBarView?.refresh() } @IBAction func onSettingsButtonClick(_ sender: Any) {