SHARE
TWEET

Untitled

a guest Jul 21st, 2019 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /// 1
  2. protocol LaunchesBusinessLogic {
  3.     func fetchLaunches(request: LaunchesPage.FetchLaunches.Request)
  4.    
  5.     ...
  6. }
  7.  
  8. /// 2
  9. protocol LaunchesDataStore {
  10.     var launches: [Launch]? { get }
  11. }
  12.  
  13. final class LaunchesInteractor: LaunchesBusinessLogic, LaunchesDataStore {
  14.     var presenter: LaunchesPresentationLogic?
  15.     var worker = LaunchesWorker()
  16.     var launches: [Launch]?
  17.     let debugMode = false
  18.  
  19.     // MARK: Fetchs launch to display during page loading
  20.    
  21.     func fetchLaunches(request: LaunchesPage.FetchLaunches.Request) {
  22.         /// 3
  23.         var response: LaunchesPage.FetchLaunches.Response!
  24.         /// 4        
  25.         worker.launchesDataManager.getLaunches(limit: nil, offset: nil).done { launches in
  26.             self.launches = launches
  27.             let filteredOrders = self.getFilteredByTypeLaunches(launches)
  28.             response = LaunchesPage.FetchLaunches.Response(launches: filteredOrders, error: nil)
  29.         }.catch { error in
  30.             response = LaunchesPage.FetchLaunches.Response(launches: nil, error: LaunchErrors.couldNotLoadLaunches(error: error.localizedDescription))
  31.         }.finally {
  32.             /// 5
  33.             self.presenter?.presentLaunches(response: response)
  34.         }
  35.     }
  36. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top