diff options
Diffstat (limited to 'foray')
-rw-r--r-- | foray/Fetchers/ForayFetcher.swift (renamed from foray/ForayNetworkManager.swift) | 4 | ||||
-rw-r--r-- | foray/Models/PenguinItemModel.swift (renamed from foray/ForayModels.swift) | 0 | ||||
-rw-r--r-- | foray/Models/PenguinItemViewModel.swift (renamed from foray/ForayViewModels.swift) | 0 | ||||
-rw-r--r-- | foray/Presenters/PenguinItemPresenter.swift | 18 |
4 files changed, 11 insertions, 11 deletions
diff --git a/foray/ForayNetworkManager.swift b/foray/Fetchers/ForayFetcher.swift index 53e9554..d8df037 100644 --- a/foray/ForayNetworkManager.swift +++ b/foray/Fetchers/ForayFetcher.swift @@ -7,9 +7,7 @@ import Foundation -class ForayNetworkManager { - static let shared = ForayNetworkManager() - +class ForayFetcher { var basicUsername: String? = nil var basicPassword: String? = nil diff --git a/foray/ForayModels.swift b/foray/Models/PenguinItemModel.swift index c721b95..c721b95 100644 --- a/foray/ForayModels.swift +++ b/foray/Models/PenguinItemModel.swift diff --git a/foray/ForayViewModels.swift b/foray/Models/PenguinItemViewModel.swift index 9b9b058..9b9b058 100644 --- a/foray/ForayViewModels.swift +++ b/foray/Models/PenguinItemViewModel.swift diff --git a/foray/Presenters/PenguinItemPresenter.swift b/foray/Presenters/PenguinItemPresenter.swift index 2f3730f..698b56e 100644 --- a/foray/Presenters/PenguinItemPresenter.swift +++ b/foray/Presenters/PenguinItemPresenter.swift @@ -8,16 +8,18 @@ import Foundation class PenguinItemPresenter { + + let fetcher = ForayFetcher() + func fetch(receiver: @escaping ([PenguinItemViewModel]) -> ()) { - ForayNetworkManager.shared - .fetch(url: "https://users.windblume.net/~nick/upload/dummy.json") { (apiItems: [PenguinItemModel]) in - // Callback to main thread here - // There probably is a nicer way to do it, but we will DispatchQueue it back - // from the Presenter-level for now (main thread from VC onwards) - DispatchQueue.main.async { - receiver(self.transform(models: apiItems)) - } + fetcher.fetch(url: "https://users.windblume.net/~nick/upload/dummy.json") { (apiItems: [PenguinItemModel]) in + // Callback to main thread here + // There probably is a nicer way to do it, but we will DispatchQueue it back + // from the Presenter-level for now (main thread from VC onwards) + DispatchQueue.main.async { + receiver(self.transform(models: apiItems)) } + } } func transform(models: [PenguinItemModel]) -> [PenguinItemViewModel] { |