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 | |
protocol Transitionable: class { | |
weak var navigationCoordinator: CoordinatorType? { get } | |
} | |
protocol CoordinatorType: class { | |
var baseController: UIViewController { 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
protocol RepositoryViewModelType: Transitionable //Make our view model Transitionable { | |
var repositorySubject: PublishSubject<Repository> { get } | |
func fetchRepositories(for observableText: Observable<String>) -> Driver<Result<[Repository]>> | |
} | |
class RepositoryViewModel : RepositoryViewModelType { | |
fileprivate let disposeBag = DisposeBag() |
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
fileprivate func setup() { | |
... older code | |
//biand a repository to the view model when the user selects a row | |
tableView | |
.rx | |
.modelSelected(Repository.self) | |
.bindTo(viewModel.repositorySubject) | |
.addDisposableTo(disposeBag) |
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 | |
import RxSwift | |
import RxAlamofire | |
import Alamofire | |
import ObjectMapper | |
enum CommonError : Error { | |
case parsingError |
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 | |
import RxSwift | |
import Alamofire | |
//this protocol represents a repository view model then anyone can implement this and perform the fetch. | |
protocol RepositoryViewModelType { | |
func fetchRepositories(for observableText: Observable<String>) -> Driver<Result<[Repository]>> | |
} |
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 RxCocoa | |
import RxSwift | |
class MainViewController: UIViewController { | |
@IBOutlet weak var tableView: UITableView! | |
@IBOutlet weak var searchBar: UISearchBar! | |
fileprivate let disposeBag = DisposeBag() |
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 | |
protocol ValueRepresentable: RawRepresentable { | |
func value() -> String | |
} | |
extension ValueRepresentable { | |
func namespaced<T: RawRepresentable>(_ key: T) -> 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
protocol Math { | |
static func +(lhs: Self, rhs: Self) -> Self | |
static func *(lhs: Self, rhs: Self) -> Self | |
init() | |
} | |
//Extend all numbers you want to | |
extension Int : Math {} | |
extension Double : Math {} |