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
/// A prefix operator that negates a `Bool` value from a given `KeyPath`. | |
/// | |
/// - Parameter keyPath: The `KeyPath` to the `Bool` value to be negated. | |
/// | |
/// - Returns: A function that takes an instance of `T` and returns the negated `Bool` value. | |
prefix func !<T>(keyPath: KeyPath<T, Bool>) -> (T) -> Bool { | |
return { !$0[keyPath: keyPath] } | |
} |
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 | |
// This is the equivalent to `CellDescriptor` https://talk.objc.io/episodes/S01E26-generic-table-view-controllers-part-2 | |
struct Handler { | |
// This is the problem... What I really need is `type` to be a concrete type that conforms to Decodable. | |
// I don't want to force users to have to conform to some arbitrary class of mine. | |
// In the case of UITableViewCell this worked out fine bc of the already-required inheritance. Is there a work around? | |
let type: Decodable.Type | |
let handle: (Decodable) -> Void |
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 Carrot | |
import SocketRocket | |
public class CarrotSocket: NSObject, Socket { | |
// MARK: Lifecycle | |
public init(webSocket: SRWebSocket) { | |
socket = webSocket |