This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| protocol LaunchListViewModelType { | |
| var launchViewModels: BehaviorRelay<[LaunchListTableViewCellViewModel]> { get } // 1 | |
| var notifyError: BehaviorRelay<Error?> { get } // 2 | |
| func fetchLaunchesWithQuery() // 3 | |
| } | |
| class LaunchListViewModel: LaunchListViewModelType { | |
| let apiService: APIServiceProtocol // 4 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class LaunchListViewController: UIViewController, UITableViewDataSource, UITableViewDelegate { | |
| @IBOutlet var tableView: UITableView! | |
| var viewModel: LaunchListViewModelType = LaunchListViewModel() | |
| var disposeBag: DisposeBag! | |
| override func viewDidLoad() { | |
| super.viewDidLoad() | |
| // Do any additional setup after loading the view. | |
| tableView.delegate = self |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct LaunchResponse: Codable, Equatable { | |
| let docs: [Launch]? | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct Launch: Codable, Equatable { | |
| let id: String? | |
| let name: String? | |
| let details: String? | |
| let date_utc: Date? | |
| let upcoming: Bool? | |
| let success: Bool? | |
| let rocket: String? | |
| init(id: String?, name: String?, details: String?, date_utc: Date?, upcoming: Bool?, success: Bool?, rocket: String?) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Alamofire | |
| protocol APIServiceProtocol { | |
| func fetchLaunchesWithQuery(startDate: Date, endDate: Date, completion: @escaping (LaunchResponse?, Error?, AFDataResponse<Any>) -> Void) -> DataRequestProtocol | |
| func fetchRocket(rocketName: String, completion: @escaping (Rocket?, Error?, AFDataResponse<Any>) -> Void) -> DataRequestProtocol | |
| } | |
| extension APIServiceProtocol { | |
| @discardableResult func fetchLaunchesWithQuery(startDate: Date = Calendar.current.date(byAdding: .year, value: -3, to: Date()) ?? Date(), endDate: Date = Date(), completion: @escaping (LaunchResponse?, Error?, AFDataResponse<Any>) -> Void) -> DataRequestProtocol { | |
| return fetchLaunchesWithQuery(startDate: startDate, endDate: endDate, completion: completion) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import UIKit | |
| import RxSwift | |
| class LaunchListViewController: UIViewController, UITableViewDataSource, UITableViewDelegate { | |
| @IBOutlet var tableView: UITableView! | |
| var viewModel: LaunchListViewModelType = LaunchListViewModel() | |
| var disposeBag: DisposeBag! | |
| override func viewDidLoad() { | |
| super.viewDidLoad() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Foundation | |
| import RxCocoa | |
| protocol LaunchListTableViewCellViewModelType { // 1 | |
| var launch: BehaviorRelay<Launch?> { get } | |
| var launchNumber: BehaviorRelay<String?> { get } | |
| var detail: BehaviorRelay<String?> { get } | |
| var hideDetail: BehaviorRelay<Bool> { get } | |
| var dateTime: BehaviorRelay<String?> { get } | |
| var statusString: BehaviorRelay<String?> { get } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Alamofire | |
| protocol APIServiceProtocol { // 1 | |
| func fetchLaunchesWithQuery(startDate: Date, endDate: Date, completion: @escaping (LaunchResponse?, Error?, AFDataResponse<Any>) -> Void) -> DataRequestProtocol | |
| func fetchRocket(rocketName: String, completion: @escaping (Rocket?, Error?, AFDataResponse<Any>) -> Void) -> DataRequestProtocol | |
| } | |
| extension APIServiceProtocol { // 2 | |
| @discardableResult func fetchLaunchesWithQuery(startDate: Date = Calendar.current.date(byAdding: .year, value: -3, to: Date()) ?? Date(), endDate: Date = Date(), completion: @escaping (LaunchResponse?, Error?, AFDataResponse<Any>) -> Void) -> DataRequestProtocol { | |
| return fetchLaunchesWithQuery(startDate: startDate, endDate: endDate, completion: completion) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "docs": [ | |
| { | |
| "fairings": { | |
| "reused": false, | |
| "recovery_attempt": false, | |
| "recovered": false, | |
| "ships": [] | |
| }, | |
| "links": { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "height": { | |
| "meters": 70, | |
| "feet": 229.6 | |
| }, | |
| "diameter": { | |
| "meters": 12.2, | |
| "feet": 39.9 | |
| }, | |
| "mass": { |
OlderNewer