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 extension Future { | |
var signal : Signal<T, E> { | |
return Signal { observer in | |
self.onSuccess(callback: observer.next) | |
self.onFailure(callback: observer.failed) | |
return observer.disposable | |
} | |
} | |
} |
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 SignalProtocol { | |
func with<T:AnyObject>(weak: T)->Signal<(Element, T), Error> { | |
weak var w = weak | |
return Signal { observer in | |
return self.observe { event in | |
switch event { | |
case .next(let element): | |
if let w = w { | |
observer.next((element, w)) | |
} |
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 static func setAuthToken(_ email:String, password: String) -> [String: String] { | |
let credentialData = "\(email):\(password)".data(using: String.Encoding.utf8)! | |
let base64Credentials = credentialData.base64EncodedString(options: []) | |
let token = "Basic \(base64Credentials)" | |
return ["Authorization": token] | |
} |
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 CGSize { | |
// get scale of image size with max dimention | |
public func scale(max: CGFloat) -> CGFloat { | |
if width > height{ | |
if width > max { | |
return max / width | |
} | |
} else { | |
if height > max { | |
return max / height |