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
| enum Stylesheet { | |
| enum Product { | |
| static let title = Style<UILabel> { | |
| $0.font = .systemFont(ofSize: 12) | |
| $0.textColor = .red | |
| $0.numberOfLines = 2 | |
| } |
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
| extension UIView { | |
| public convenience init<V>(style: Style<V>) { | |
| self.init(frame: .zero) | |
| apply(style) | |
| } | |
| public func apply<V>(_ style: Style<V>) { | |
| guard let view = self as? V else { | |
| print("💥 Could not apply style for \(V.self) to \(type(of: self))") |
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
| public struct Style<View: UIView> { | |
| public let style: (View) -> Void | |
| public init(_ style: @escaping (View) -> Void) { | |
| self.style = style | |
| } | |
| public func apply(to view: View) { | |
| style(view) |
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
| public class ProductView: UIView { | |
| public let titleLabel: UILabel = { | |
| let label = UILabel() | |
| label.font = .systemFont(ofSize: 12) | |
| label.textColor = .red | |
| label.numberOfLines = 2 | |
| return label | |
| }() |
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
| public class Authentication { | |
| public typealias Credentials = (username: String, password: String) | |
| public enum Response { | |
| case authenticated(Token) | |
| case failed(String) | |
| } | |
| public let credentials: SafeObserver<Credentials> |
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
| open class Client { | |
| open func response<Resource, Error: Swift.Error>(for request: Request<Resource, Error>) -> Signal<Resource, Client.Error> | |
| } | |
| public class SafeClient { | |
| public let errors = SafeSignal<UserFriendlyError>() | |
| public init(wrapping client: Client) | |
| public func response<Resource, Error: Swift.Error>(for request: Request<Resource, Error>) -> SafeSignal<Resource> | |
| } |
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
| public struct LocalDate { | |
| public let day: Int | |
| public let month: Int | |
| public let year: Int | |
| public init(day: Int, month: Int, year: Int) { | |
| self.day = day | |
| self.month = month | |
| self.year = year | |
| } |
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
| extension RecipeList { | |
| public func createScene() -> UIViewController { | |
| let vc = ViewController.RecipeList() | |
| vc.sortDescriptorPickerView.reactive.selectedDescriptor | |
| .observe(with: sortDescriptor) | |
| .dispose(in: vc.reactive.bag) |
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
| extension Authentication { | |
| public typealias Scene = ( | |
| viewController: UIViewController, | |
| token: SafeSignal<Token> | |
| ) | |
| public func createScene() -> Scene { | |
| let vc = ViewController.Authentication() |
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
| extension Interactor { | |
| public func createScene() -> Output { | |
| ... | |
| } | |
| } |