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
| /// Returns a binary predicate using the given key path to create an ascending order | |
| /// for elements of type `Root`. | |
| func ascending<Root, Value: Comparable>(_ path: KeyPath<Root, Value>) -> (Root, Root) -> Bool { | |
| return { $0[keyPath: path] < $1[keyPath: path] } | |
| } | |
| /// Returns a binary predicate using the given key path to create a descending order | |
| /// for elements of type `Root`. | |
| func descending<Root, Value: Comparable>(_ path: KeyPath<Root, Value>) -> (Root, Root) -> Bool { | |
| return { $0[keyPath: path] > $1[keyPath: path] } |
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 Foundation | |
| // Written in Swift 4.2, Xcode 10 beta 6 | |
| // Valid Identifier Heads found at: https://docs.swift.org/swift-book/ReferenceManual/LexicalStructure.html | |
| // Code inspired by Nate Cooks gist: https://gist.github.com/natecook1000/c5fb2b8cd0967f53770e | |
| extension UnicodeScalar : Strideable { |
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
| typealias NoArgMethod<StrongObject, ReturnType> = (StrongObject) -> () -> ReturnType | |
| typealias SingleArgumentMethod<Argument, StrongObject> = (StrongObject) -> (Argument) -> Void | |
| func unown<O, R>( | |
| _ object: O, // This is strong | |
| _ method: @escaping NoArgMethod<O, R> | |
| ) -> () -> R where O: AnyObject, R: Any | |
| { | |
| return { [unowned object] in |
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 ViewModelType { | |
| associatedtype Input | |
| associatedtype Output | |
| func transform(input: Input) -> Output | |
| } |
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
| /* This ⬇ single line ⬇ constitutes a fully working ViewController. Clean code 👌🏽 */ | |
| typealias Settings = Scene<SettingsView> |
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 RxSwift | |
| import RxCocoa | |
| // MARK: - SettingsView | |
| final class SettingsView: ScrollingStackView { | |
| private lazy var signOutButton: UIButton = "Sign out" | |
| // Two `UILabel`s grouped together |
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 RxCocoa | |
| protocol EmptyInitializable { | |
| init() | |
| } | |
| protocol ViewModelled: EmptyInitializable { | |
| associatedtype ViewModel: ViewModelType | |
| var inputFromView: ViewModel.Input { 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
| import UIKit | |
| import RxSwift | |
| import RxCocoa | |
| final class AuthenticateView: UIView { | |
| private lazy var signUpButton = UIButton(type: .custom) | |
| private lazy var signInButton = UIButton(type: .custom) | |
| private lazy var stackView = UIStackView(arrangedSubviews: [signUpButton, signInButton]) |
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 RxSwift | |
| protocol EmptyInitializable { | |
| init() | |
| } | |
| protocol ViewModelled: EmptyInitializable { | |
| associatedtype ViewModel: ViewModelType |