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
protocol ViewRepresentable: ViewModelTypeErasedViewRepresentable { | |
associatedtype ViewModelType: ViewModel | |
var model: ViewModelType! { get set } | |
func bindWithModel() | |
} | |
protocol ViewModelTypeErasedViewRepresentable: class { | |
var typeErasedViewModel: ViewModel? { get set } |
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 ViewDependency: ExpressibleByStringLiteral { | |
typealias StringLiteralType = String | |
var nibName: String | |
var identifier: String | |
var classType: AnyClass | |
var withNib = true | |
var isCell = true | |
var kind = "" | |
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
protocol CollectionItemsViewModelDependencyManager { | |
var dependencies: [ViewDependency] { get } | |
func mapModelTypeNameToIdentifier(_ fullTypeName: String) -> String | |
func reuseIdentifier(for model: CollectionItemViewModel) -> String | |
func resolveIdentifier(forModelTypeUsingUnusualNaming fullTypeName: String) -> String | |
} | |
extension CollectionItemsViewModelDependencyManager { | |
func reuseIdentifier(for model: CollectionItemViewModel) -> 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
protocol CollectionItemsViewModelDependencyManager { | |
var dependencies: [ViewDependency] { get } | |
func mapModelTypeNameToIdentifier(_ fullTypeName: String) -> String | |
func reuseIdentifier(for model: CollectionItemViewModel) -> String | |
func resolveIdentifier(forModelTypeUsingUnusualNaming fullTypeName: String) -> String | |
} | |
extension CollectionItemsViewModelDependencyManager { | |
func reuseIdentifier(for model: CollectionItemViewModel) -> 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
protocol ViewModel { | |
func setup() | |
} | |
extension ViewModel { | |
func 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
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>bundleid</key> | |
<string>[your-app-bundle-id]</string> | |
<key>config</key> | |
<dict></dict> | |
<key>policy</key> | |
<dict></dict> |
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
public func urlSession(_ session: URLSession, task: URLSessionTask, willPerformHTTPRedirection response: HTTPURLResponse, newRequest request: URLRequest, completionHandler: @escaping (URLRequest?) -> Void) { | |
guard let newRequest = (request as NSURLRequest).mutableCopy() as? NSMutableURLRequest else { | |
completionHandler(request) | |
return | |
} | |
if let cookies = HTTPCookieStorage.shared.cookies { | |
newRequest.allHTTPHeaderFields = HTTPCookie.requestHeaderFields(with: cookies) | |
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 Bond | |
class ViewController: UIViewController { | |
@IBOutlet weak var greetingLabel: UILabel! | |
@IBOutlet weak var nameTextField: UITextField! | |
@IBOutlet weak var sayHelloButton: UIButton! | |
let model = ViewModel() | |
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 | |
import Bond | |
class ViewModel { | |
let name = Observable<String?>(nil) | |
let greeting = Observable<String?>(nil) | |
lazy var sayHelloCommand: ActionCommand = { | |
return ActionCommand { [unowned self] in | |
self.sayHello() | |
} |
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 | |
import Bond | |
class ActionCommand: Command { | |
typealias Element = Void | |
private var actionBlock: () -> () | |
init(_ actionBlock: @escaping () -> ()) { | |
self.actionBlock = actionBlock | |
} |