From 1752ea7075939fb49dd72e0b8ea2accc2be1b02a Mon Sep 17 00:00:00 2001 From: Nicholas Tay Date: Fri, 25 Mar 2022 09:59:35 +1100 Subject: Reorganise: NetworkManager -> Fetcher, Models -> dedicated groups --- foray/Presenters/PenguinItemPresenter.swift | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'foray/Presenters') 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] { -- cgit