Skip to content

Commit

Permalink
Change refresh interval to timer in order to subscribe without a delay
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrejJurkin committed Sep 28, 2017
1 parent 7c03a4e commit 4668f61
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Nova/repository/DataRepository.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -134,7 +135,7 @@ class DataRepository {
self.tickerUpdateSubscription?.dispose()

self.tickerUpdateSubscription =
Observable<Int>.interval(RxTimeInterval(refreshInterval), scheduler: Schedulers.background)
Observable<Int>.timer(0, period: RxTimeInterval(refreshInterval), scheduler: Schedulers.background)
// Query Cryptonator api for an update
.flatMap { _ -> Observable<[String: [String: Double]]> in
print("Pinned tickers updated")
Expand Down Expand Up @@ -165,7 +166,7 @@ class DataRepository {
self.globalRefreshSubscription?.dispose()

self.globalRefreshSubscription =
Observable<Int>.interval(RxTimeInterval(refreshIntervalMinutes * 60), scheduler: Schedulers.background)
Observable<Int>.timer(0, period: RxTimeInterval(refreshIntervalMinutes * 60), scheduler: Schedulers.background)
// Query Cryptonator api for an update
.flatMap { _ -> Observable<[Ticker]> in

Expand Down
2 changes: 2 additions & 0 deletions Nova/view/tickerlist/TickerListViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 4668f61

Please sign in to comment.