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
struct Page<Model: Decodable>: Decodable { | |
let page: UInt | |
let total_results: UInt | |
let total_pages: UInt | |
let results: [Model] | |
} |
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
final class MovieManager { | |
func getDiscoverMovies(_ completion: @escaping (Page<Movie>?) -> Void) { | |
let completionOnMainThread = { result in | |
DispatchQueue.main.async { | |
completion(result) | |
} | |
} | |
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: - Error | |
enum MovieManagerError: Error { | |
case oops | |
} | |
// MARK: - Manager | |
protocol MovieManaging { | |
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
@UIApplicationMain | |
class AppDelegate: UIResponder, UIApplicationDelegate { | |
var window: UIWindow? | |
private let dependencies: AppDelegateDependencyResolver = AppDelegateDependencyContainer() | |
// weaver: homeViewController = HomeViewController <- UIViewController | |
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> 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 UIKit | |
final class MovieTableViewCell: UITableViewCell { | |
struct ViewModel { | |
let title: String | |
} | |
func bind(_ viewModel: ViewModel) { | |
textLabel?.text = viewModel.title |
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
struct Movie: Decodable { | |
let vote_count: UInt | |
let id: UInt | |
let video: Bool | |
let vote_average: Float | |
let title: String | |
let popularity: Float | |
let poster_path: String | |
let original_language: String | |
let original_title: 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 UIKit | |
@UIApplicationMain | |
class AppDelegate: UIResponder, UIApplicationDelegate { | |
var window: UIWindow? | |
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { | |
window = UIWindow() |
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
final class MoviesViewController: UIViewController { | |
private let dependencies: MoviesViewControllerDependencyResolver | |
// weaver: movieManager <- MovieManaging | |
required init(injecting dependencies: MoviesViewControllerDependencyResolver) { | |
self.dependencies = dependencies | |
super.init(nibName: nil, bundle: nil) | |
} |
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
final class MovieManagerTests: XCTestCase { | |
private var storeSpy: KeyValueStoreSpy! | |
private var clientSpy: ClientSpy! | |
private var movieManager: MovieManaging! | |
override func setUp() { | |
super.setUp() |
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
final class KeyValueStoreSpy: KeyValueStoring { | |
// MARK: - Records | |
private(set) var keyRecords = [String]() | |
private(set) var valueRecords = [StoreValueRepresentable]() | |
// MARK: - Stubs |