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 Combine | |
precedencegroup SinkPrecedence { } | |
precedencegroup FilterPrecedence { | |
associativity: left | |
higherThan: SinkPrecedence | |
} | |
infix operator | : FilterPrecedence |
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
// | |
// Usage: | |
// | |
// Facebook: | |
// | |
// 1. Follow this guide (WITHOUT setting up a URL scheme in Xcode): | |
// https://github.com/fullstackreact/react-native-oauth/issues/76#issuecomment-335902057 | |
// | |
// 2. call startFacebookAuthenticationSession(appID:completionHandler:) on a window: | |
// |
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
enum Equality<T: Equatable> { | |
case equal(T) | |
case notEqual | |
} | |
func == <T: Equatable>(lhs: T, rhs: T) -> Equality<T> { | |
if lhs == rhs { | |
return .equal(lhs) | |
} else { | |
return .notEqual |
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 | |
let json = """ | |
{ | |
"results":[ | |
{ | |
"blah":"blah", | |
"nested_object":{ | |
"type":"a", | |
"id":69, |
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
@dynamicMemberLookup | |
protocol JSONType { | |
subscript(dynamicMember member: String) -> JSONType? { get set } | |
} | |
extension JSONType { | |
subscript(dynamicMember member: String) -> JSONType? { | |
get { nil } | |
set { } | |
} | |
subscript<T>(type: T.Type) -> T? { |
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 | |
typealias MutableContext<Value> = (@escaping (inout Value) -> Void) -> Void | |
class MasterViewController: UITableViewController { | |
var models = [String]() | |
// 點選 cell 時會呼叫的工廠方法。 | |
func makeDetailViewController(indexPath: IndexPath) -> DetailViewController? { |
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
func makeObject() -> (getter: () -> String, setter: (String) -> Void) { | |
var text = "Hello " | |
return ( | |
getter: { text }, | |
setter: { text = $0 } | |
) | |
} | |
let object = makeObject() |
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
// MARK: Core | |
public typealias DeactivateHandler = () -> Void | |
public struct AsyncTask<Success, Failure> where Failure: Error { | |
public var activate: (@escaping (Success) -> Void, @escaping (Failure) -> Void) -> DeactivateHandler | |
} | |
extension AsyncTask where Failure == Never { |
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
@dynamicMemberLookup | |
public struct FluentInterface<Root> { | |
public let root: Root | |
public subscript<Value>(dynamicMember keyPath: WritableKeyPath<Root, Value>) -> (Value) -> Self { | |
var root = self.root | |
return { newValue in | |
root[keyPath: keyPath] = newValue | |
return FluentInterface(root: root) | |
} |
NewerOlder