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
| func fetchData(request: NSURLRequest) -> SignalProducer<[Foo], Error> { | |
| return foosFromServer(request).flatMapError {_ in //network failed deal with it} | |
| .flatMapLatest { parseFoos($0).flatMapError {_ in //parse failed deal with it} } | |
| .flatMapLatest { persistFoos($0).flatMapError {_ in //persist failed deal with it} } | |
| .flatMapError { error in loadFoosFromCache().mapError {_ in error} } | |
| } |
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
| protocol Foo { | |
| typealias T: Hashable | |
| var foos: [T] { get } | |
| } | |
| struct Bar<T: Equatable>: Foo { | |
| let foos: [T] | |
| init(foos: [T]) { |
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
| import Foundation | |
| import ReactiveCocoa | |
| final class PriorityAction<T> { | |
| let identifier : String | |
| let action : Action<Void, [T], Error> | |
| init(identifier: String, action: Action<Void, [T], Error>) { | |
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 final class Box<T> | |
| { | |
| let value : T | |
| public init(_ value : T) { | |
| self.value = value | |
| } | |
| } | |
| func flatten<T>(box : Box<Box <T>>) -> Box <T> { |
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
| func curry<T,U,V>(f:(T,U)->V) -> T -> U -> V | |
| { | |
| return {x in { y in f(x,y)}} | |
| } | |
| extension Array { | |
| var decompose : (T,[T])? { | |
| return (count > 0) ? (self[0], Array(self[1..<count])) : nil | |
| } | |
| } |
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
| //The magic method | |
| -(id (^)(id,...)) getSelector:(SEL) aSelector forTarget:(id) target withFirstArgument:(id) firstArgument { | |
| id (^blockName)(id,...) = ^id(id values,...) { | |
| id cenas = firstArgument; | |
| SEL theSelector; | |
| NSMethodSignature *aSignature; | |
| NSInvocation *anInvocation; |
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
| func sum(lhs : Int)(rhs : Int) -> Int { | |
| return lhs + rhs | |
| } | |
| let sum2 = sum (2) | |
| let pair1 = sum2(rhs: 1) | |
| let pair2 = sum2(rhs: 2) | |
| let pair3 = sum2(rhs: 3) | |
| let pair4 = sum2(rhs: 4) |
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
| func something() (int,int) { | |
| return 1,2 | |
| } |
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
| //The calculations are coming from [here](https://gist.github.com/d-ronnqvist/11266321) (thanks David!) | |
| - (void)updateAnimations | |
| { | |
| CGFloat duration = self.duration * (1.f - [[self.progressLayers firstObject] strokeEnd]); | |
| CGFloat strokeEndFinal = 1.f; | |
| for (CAShapeLayer *progressLayer in self.progressLayers) | |
| { | |
| POPBasicAnimation *popEndAnimation = [POPBasicAnimation animation]; |
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
| Pod::Spec.new do |s| | |
| s.name = "ReactiveCocoa" | |
| s.version = "2.3" | |
| s.summary = "A framework for composing and transforming streams of values." | |
| s.homepage = "https://github.com/blog/1107-reactivecocoa-is-now-open-source" | |
| s.author = { "Josh Abernathy" => "[email protected]" } | |
| s.source = { :git => "https://github.com/ReactiveCocoa/ReactiveCocoa.git", :tag => "v#{s.version}" } | |
| s.license = 'MIT' | |
| s.description = "ReactiveCocoa (RAC) is an Objective-C framework for Functional Reactive Programming. It provides APIs for composing and transforming streams of values." | |