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 UIKit | |
typealias CountryListViewModelProtocol = CountryListDatasource & ViewModel & Searchable | |
protocol CountryListDatasource { | |
var screenTitle: String { get } | |
var numberOfSections: Int { get } | |
func numberOfRows(in section: Int) -> Int | |
func itemForRow(at indexPath: IndexPath) -> CountryListItemRepresentable |
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 UIKit | |
final class CountryListCoordinator: Coordinator { | |
private enum LocalizedStrings { | |
static let okTitle = "Ok" | |
static let errorTitle = "Error" | |
static let errorMessage = "Could not search country for the keyword." | |
} |
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 XCTest | |
@testable import MVVMCDemo | |
class CountryListViewModelTests: XCTestCase { | |
func testEndpoint() { | |
let requestManager = LocalRequestManager() | |
let sut = CountryListViewModel(requestManager: requestManager) | |
sut.searchFor(keyword: "test") | |
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 XCTest | |
@testable import MVVMCDemo | |
class CountryListCoordinatorTests: XCTestCase { | |
private let sut = CountryListCoordinator(requestManager: LocalRequestManager()) | |
func testStart() { | |
XCTAssertTrue(sut.start() is CountryListViewController) | |
} |
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 | |
/// This protocol defines basic responsibility for `ViewModel` | |
protocol ViewModel { | |
/// This method is called when `ViewModel` updates itself with `new` data | |
var didUpdate: (() -> Void)? { get set } | |
/// This method is called when `ViewModel` changes its state | |
/// - isLoading: Loading state of ViewModel | |
/// - loadingMessage: Loading messages to display while ViewModel is loading |
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 Coordinator: class { | |
var childCoordinators: [Coordinator]? { get set } | |
func start() -> UIViewController | |
var finished: (() -> Void)? { get set } | |
} |
OlderNewer