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
struct RectangleConfig { | |
var width: Int = 0 | |
var height: Int = 0 | |
} | |
class ConfigView: NSView { | |
// Models | |
let config = MutableProperty<RectangleConfig?>(nil) | |
var width: SignalProducer<Int?, NoError>! |
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
extension Signal where Error == NoError { | |
public func sample(each timeInterval: DispatchTimeInterval, | |
on scheduler: DateScheduler = QueueScheduler()) -> Signal<[Value], NoError> { | |
return Signal<[Value], NoError> { observer in | |
let valueHolder : MutableProperty<[Value]> = MutableProperty<Value>([]) | |
let disposable = CompositeDisposable() | |
var sampler: Signal<(), NoError>? = nil | |
disposable += timer(interval: until, on: QueueScheduler()).startWithSignal { signal, _ in | |
signal = innerSignal.map { _ in () } | |
} |
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
@interface NSObject (Cast) | |
+ (instancetype)cast:(id)object; | |
@end |
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
@interface DBManager<ObjCType, CPPType> : NSObject | |
- (ObjCType)performOperation:(darkmatter::Result<CPPType> (^)())operation | |
withMap:(ObjCType (^)(darkmatter::Result<CPPType> fetchedObject))map | |
returningError:(NSError **)error; | |
@end | |
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
@interface StringContainer : NSObject | |
- (instancetype)initWithString:(NSString *)string; | |
@property (nonatomic, unsafe_unretained) NSString *string; | |
@end | |
@implementation StringContainer | |
- (instancetype)initWithString:(NSString *)string { |
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
Thread 5Queue : com.apple.root.user-initiated-qos (concurrent) | |
#0 0x000000010f181d2b in objc_release () | |
#1 0x000000010f1831d1 in (anonymous namespace)::AutoreleasePoolPage::pop(void*) () | |
#2 0x00000001125037ce in _dispatch_root_queue_drain () | |
#3 0x0000000112503059 in _dispatch_worker_thread3 () | |
#4 0x00000001128cb4de in _pthread_wqthread () | |
#5 0x00000001128c9341 in start_wqthread () |
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
//: Playground - noun: a place where people can play | |
import Foundation | |
prefix operator ~ | |
prefix func ~<Entity, Parameters>(_ param: ((Entity) -> (Parameters) -> (), Entity)) -> WeakCallback<Parameters> | |
where Entity: AnyObject | |
{ | |
return WeakCallback.weakifyFunction(param.0, object: param.1) |
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
//: Playground - noun: a place where people can play | |
import Foundation | |
precedencegroup boolImply { | |
associativity: left | |
} | |
infix operator ~>: boolImply |
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
//: Playground - noun: a place where people can play | |
import Foundation | |
func work<R, T0>(_ f: @escaping (T0) -> R) -> (T0) -> R { | |
return { (arg0: T0) -> R in return f(arg0) } | |
} | |
func work<R, T0, T1>(_ f: @escaping (T0, T1) -> R) -> (T0, T1) -> R { | |
return { (arg0: T0, arg1: T1) -> R in return f(arg0, arg1) } |
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
public protocol A { | |
associatedtype V | |
associatedtype E | |
var a: V { get } | |
} | |
public protocol B { | |
associatedtype V | |
var b: V { get } | |
} |