This file contains 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 RxSwift | |
import ReactiveCoordinator | |
class HolidayDetailCoordinator: ReactiveCoordinator<Void> { | |
private let rootViewController: UIViewController | |
public var viewModel: HolidayViewModel! | |
init(rootViewController: UIViewController) { | |
self.rootViewController = rootViewController |
This file contains 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 HolidayDetailViewController: UIViewController { | |
// MARK: - Lifecycle Methods | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
.... | |
bindViewModel() | |
} | |
override func viewWillDisappear(_ animated: Bool) { |
This file contains 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 RxSwift | |
import ReactiveCoordinator | |
enum ChooseCountryCoordinationResult { | |
case country(String) | |
case cancel | |
} | |
class ChooseCountryCoordinator: ReactiveCoordinator<ChooseCountryCoordinationResult> { | |
This file contains 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 | |
import RxCocoa | |
class ChooseCountryViewController: UIViewController { | |
// MARK: - Lifecycle Methods | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
setupUI() |
This file contains 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 | |
class CountryTableViewCell: UITableViewCell { | |
// MARK: - Initialization | |
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { | |
super.init(style: style, reuseIdentifier: reuseIdentifier) | |
setupUI() | |
} | |
This file contains 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 RxSwift | |
import RxCocoa | |
final class ChooseCountryViewModel { | |
private let disposeBag = DisposeBag() | |
// MARK: - Actions | |
let didClose = PublishSubject<Void>() | |
let selectedCountry = PublishSubject<String>() | |
This file contains 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 RxSwift | |
import RxCocoa | |
struct CountryViewModel { | |
let code: String | |
let name: String | |
init(country: Country) { | |
self.code = country.code! | |
self.name = country.name! |
This file contains 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 | |
class APIManager { | |
.... | |
lazy var apiKey: String = { | |
return "PASTE YOUR API KEY HERE" | |
}() | |
This file contains 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
// MARK: - Binding | |
extension HolidaysViewController { | |
func bindTableView() { | |
viewModel.holidays | |
.bind(to: tableView.rx.items(cellIdentifier: "HolidayTableViewCell", cellType: HolidayTableViewCell.self)) { index, viewModel, cell in | |
cell.viewModel = viewModel | |
} | |
.disposed(by: disposeBag) | |
This file contains 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 APIClient { | |
..... | |
func get<T: BaseMappable>(urlString: String, parameters: [String: Any] = [:], success: @escaping (Int, T) -> (), failure: @escaping (String) -> ()) { | |
var parameters = parameters | |
parameters["key"] = APIManager.shared.apiKey | |
guard let url = NSURL(string: urlString , relativeTo: self.baseURL as URL?) else { | |
return |