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 | |
func invocation<C: AnyObject, In, Out> | |
(target target: C, method: C -> In -> Out) | |
-> In -> Out? | |
{ | |
return { | |
[weak target] input in | |
if let target = target { | |
return method(target)(input) |
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 CollectionType where Index: RandomAccessIndexType { | |
/// Finds such index N that predicate is true for all elements up to | |
/// but not including the index N, and is false for all elements | |
/// starting with index N. | |
/// Behavior is undefined if there is no such N. | |
func binarySearch(predicate: Generator.Element -> Bool) -> Index { | |
var low = startIndex | |
var high = endIndex | |
while low != high { |
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 animatingContext(duration: TimeInterval) -> ((@escaping (Void) -> Void) -> Void) { | |
return { UIView.animate(withDuration: duration, animations: $0) } | |
} | |
public extension SignalProtocol { | |
public func observe(context: @escaping (@escaping (Void) -> Void) -> Void) -> Signal<Value, Error> { | |
return Signal { observer in | |
return self.observe { event in | |
switch event { | |
case .value: |