Skip to content

Instantly share code, notes, and snippets.

View IsaAliev's full-sized avatar

Isa Aliev IsaAliev

  • Moscow, Russia
View GitHub Profile
protocol ViewRepresentable: ViewModelTypeErasedViewRepresentable {
associatedtype ViewModelType: ViewModel
var model: ViewModelType! { get set }
func bindWithModel()
}
protocol ViewModelTypeErasedViewRepresentable: class {
var typeErasedViewModel: ViewModel? { get set }
struct ViewDependency: ExpressibleByStringLiteral {
typealias StringLiteralType = String
var nibName: String
var identifier: String
var classType: AnyClass
var withNib = true
var isCell = true
var kind = ""
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 {
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 {
protocol ViewModel {
func setup()
}
extension ViewModel {
func setup() {}
}
<?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>
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)
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()
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()
}
import Foundation
import Bond
class ActionCommand: Command {
typealias Element = Void
private var actionBlock: () -> ()
init(_ actionBlock: @escaping () -> ()) {
self.actionBlock = actionBlock
}