aboutsummaryrefslogtreecommitdiff
path: root/foray/Presenters
diff options
context:
space:
mode:
authorNicholas Tay <nick@windblume.net>2022-03-25 09:59:35 +1100
committerNicholas Tay <nick@windblume.net>2022-03-25 09:59:35 +1100
commit1752ea7075939fb49dd72e0b8ea2accc2be1b02a (patch)
tree04ad843bc6b05d31cc6524cffe652229e8da0ffd /foray/Presenters
parent07a6eb8325d3b67d998003d3fe5ab34e1a72f106 (diff)
downloadforayios-1752ea7075939fb49dd72e0b8ea2accc2be1b02a.tar.gz
forayios-1752ea7075939fb49dd72e0b8ea2accc2be1b02a.tar.bz2
forayios-1752ea7075939fb49dd72e0b8ea2accc2be1b02a.zip
Reorganise: NetworkManager -> Fetcher, Models -> dedicated groups
Diffstat (limited to 'foray/Presenters')
-rw-r--r--foray/Presenters/PenguinItemPresenter.swift18
1 files changed, 10 insertions, 8 deletions
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] {